當前位置: 首頁>>代碼示例>>C#>>正文


C# Model.User類代碼示例

本文整理匯總了C#中Model.User的典型用法代碼示例。如果您正苦於以下問題:C# User類的具體用法?C# User怎麽用?C# User使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


User類屬於Model命名空間,在下文中一共展示了User類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: AddUserAndRetId

 public int AddUserAndRetId(User user)
 {
     StringBuilder strSql = new StringBuilder();
     strSql.Append("insert into [users]");
     strSql.Append("(username,passwd) output inserted.uid values");
     strSql.Append("(@UserName,@PassWord)");
     SqlParameter[] parameters = {
                                     new SqlParameter("@UserName",SqlDbType.VarChar,16),
                                     new SqlParameter("@PassWord",SqlDbType.VarChar,64)
                                 };
     parameters[0].Value = user.UserName;
     parameters[1].Value = user.Password;
     SqlDataReader reader = SqlDbHelper.ExecuteReader(strSql.ToString(), CommandType.Text, parameters);
     try
     {
         if (reader.Read())
         {
             return Int16.Parse(reader[0].ToString());
         }
     }
     catch
     {
         return -1;
     }
     finally
     {
         reader.Close();
     }
     return -1;
 }
開發者ID:qq5013,項目名稱:Medical,代碼行數:30,代碼來源:UserDALImp.cs

示例2: LogIn

		public void LogIn(String username, String password, bool rememberme, string ReturnUrl)
		{
			// We should authenticate against a database table or something similar
			// but here, everything is ok as long as the 
			// password and username are non-empty
			
			if (IsValid(username, password))
			{
				CancelView();
				
				// Ideally we would look up an user from the database
				// The domain model that represents the user
				// could implement IPrincipal or we could use an adapter
				
				User user = new User(username, new string[0]);
				
				Session["user"] = user;
				
				Redirect(ReturnUrl);
			}
			else
			{
				// If we got here then something is wrong 
				// with the supplied username/password
			
				Flash["error"] = "Invalid user name or password. Try again.";
				RedirectToAction("Index", "ReturnUrl=" + ReturnUrl);
			}
		}
開發者ID:ralescano,項目名稱:castle,代碼行數:29,代碼來源:LoginController.cs

示例3: SeedDatabase

        protected static void SeedDatabase(FluentModel context)
        {
            User usr1 = new User()
            {
                UserId = 1,
                Name = "Gary Adkins",
                Note = "note note note",
                Email = "[email protected]",
                Income = 10000.324m
            };

            User usr2 = new User()
            {
                UserId = 2,
                Name = "Tim Gordon",
                Note = "note note note",
                Email = "[email protected]",
                Income = 10000.324m
            };

            User usr3 = new User()
            {
                UserId = 3,
                Name = "Jack Jameson",
                Note = "note note note",
                Email = "[email protected]",
                Income = 10000.324m
            };

            User usr4 = new User()
            {
                UserId = 4,
                Name = "Bill Tompson",
                Note = "note note note",
                Email = "[email protected]",
                Income = 10000.324m
            };

            Group administratorsGroup = new Group()
            {
                GroupId = 1,
                Name = "Administrators",
                Description = "admin group description",
            };
            administratorsGroup.UsersInGroup.Add(usr1);
            administratorsGroup.UsersInGroup.Add(usr2);

            Group coreUsersGroup = new Group()
            {
                GroupId = 2,
                Name = "Core users",
                Description = "core users description"
            };
            coreUsersGroup.UsersInGroup.Add(usr3);
            coreUsersGroup.UsersInGroup.Add(usr4);

            context.Add(administratorsGroup);
            context.Add(coreUsersGroup);
            context.SaveChanges();
        }
開發者ID:BilalShami,項目名稱:data-access-samples,代碼行數:60,代碼來源:BaseTestClass.cs

示例4: RegisterUser_CreatedUser

    protected void RegisterUser_CreatedUser(object sender, EventArgs e)
    {
        #region ["Method FormsAutentication"]
            //FormsAuthentication.SetAuthCookie(RegisterUser.UserName, false /* createPersistentCookie */);

            //string continueUrl = RegisterUser.ContinueDestinationPageUrl;
            //if (String.IsNullOrEmpty(continueUrl))
            //{
            //    continueUrl = "~/";
            //}
            //Response.Redirect(continueUrl);
        #endregion
        string continueUrl = "";
        Model.User _userM = new Model.User();
        FAMIS_BLL.User _userB = new FAMIS_BLL.User();

        _userM.Login = RegisterUser.UserName;
        _userM.Password = RegisterUser.Password;
        string sRet = _userB.Add(_userM);
        if (sRet == "")
        {
            continueUrl = "~/";
        }
        Response.Redirect(continueUrl);
    }
開發者ID:ecmr,項目名稱:FAMIS,代碼行數:25,代碼來源:Register.aspx.cs

示例5: btn_Add_Click

    protected void btn_Add_Click(object sender, EventArgs e)
    {
        if (txt_Name.Text.Trim().ToLower() == "admin")
        {
            UtilityService.Alert(this.Page,"admin是非法用戶名,請換一個用戶名稱!");
            return;
        }

        Model.User u = new Model.User();
        u.UserID = txt_UM.Text.Trim();
        u.UserName = txt_Name.Text.Trim();
        //u.Password = txt_Pwd.Text.Trim();
        u.Status = 1;
        u.OrganID = int.Parse(ddl_Organ.SelectedValue.ToString());//(int)Session["OrganID"];
        u.OpenDate = DateTime.Parse(txt_OpenDate.Text);
        u.InputBy = Session["UserID"].ToString();

        DataSet oldU = new UserBLL().GetList(" UserID = '" + u.UserID + "'");
        if (oldU != null && oldU.Tables[0].Rows.Count > 0)
        {
            UtilityService.Alert(this, "該用戶名已存在!");
            return;
        }

        int re = new UserBLL().Add(u);
        if (re > 0)
        {
            UtilityService.AlertAndRedirect(this, "添加成功!", "UserMgr.aspx");
        }
        else
        {
            UtilityService.Alert(this, "添加失敗!");
        }
    }
開發者ID:kavilee2012,項目名稱:lzQA,代碼行數:34,代碼來源:UserAMV.aspx.cs

示例6: frmPaymentTermial

 /// <summary>
 /// 無參構造函數
 /// 內容初始化為測試模式
 /// 需要參數的內容為null
 /// </summary>
 public frmPaymentTermial()
 {
     labelTitle.Text = frmSetting.paymentTitle;
     user = new User("pirat", -1, "-1") ;
     supermarket = null;
     InitializeComponent();
 }
開發者ID:piratf,項目名稱:supermarketManageSystem,代碼行數:12,代碼來源:frmPaymentTermial.cs

示例7: frmMain

 /// <summary>
 /// 無參構造基本窗體
 /// </summary>
 public frmMain()
 {
     InitializeComponent();
     user = new User("piratf", -1, "-1");
     wn = null;
     wt = null;
 }
開發者ID:piratf,項目名稱:supermarketManageSystem,代碼行數:10,代碼來源:frmMain.cs

示例8: Clone

 public User Clone(User _user)
 {
     this.userID = _user.userID;
     this.level = _user.level;
     this.supermarket = _user.supermarket;
     return this;
 }
開發者ID:piratf,項目名稱:supermarketManageSystem,代碼行數:7,代碼來源:User.cs

示例9: SaveUser

        public ActionResult SaveUser(User user)
        {
            user.CurrentCompany = CompanyManager.Get(user.CurrentCompany.CompanyID);
            UserManager.Save(user);

            return RedirectToAction("GetCompany", "Home", new { id = user.CurrentCompany.CompanyID });
        }
開發者ID:CharmingJune,項目名稱:springnetalldemo3,代碼行數:7,代碼來源:HomeController.cs

示例10: Can_Add_User

        public void Can_Add_User()
        {
            // Arrange .. create the user
            string displayName = "Galilyou";
            string email = "[email protected]";

            User user = new User();

            user.DisplayName = displayName;
            user.Email = email;

            IUserRepository repository = _serviceLocator.Locate<IUserRepository>();

            // act ...
            repository.Add(user);

            // now try to  get the saved in user
            var tryToFindUser = repository.Filter(
                c => c.DisplayName == displayName,
                c => c.Email == email
                );

            // assert
            Assert.Greater(tryToFindUser.Count(), 0);
        }
開發者ID:Galilyou,項目名稱:EFDemo,代碼行數:25,代碼來源:UserTests.cs

示例11: Connection_Connect_Behaviour_DisconnectUnconnectedUser

        public void Connection_Connect_Behaviour_DisconnectUnconnectedUser()
        {
            User dummy = new User() { Name = "Crash Test Dummy", Password = "Not again!" };
            PieServiceClient pieService = new PieServiceClient();

            pieService.Disconnect(dummy);
            //It's okay to disconnect a user even if he isn't connected
        }
開發者ID:Yndal,項目名稱:BDSA-Project-2012,代碼行數:8,代碼來源:PieServiceTest.cs

示例12: CreateNewUser

		public User CreateNewUser(string username, string password, string email)
		{
			var author = new User {UserName = username, Password = password, Email = email};
			_userRepository.SaveUser(author);
			var userRegistered = new UserRegisteredEventArgs(this, author);
			UserRegistered.Raise(userRegistered);
			return author;
		}
開發者ID:DogaOztuzun,項目名稱:BlogSharp,代碼行數:8,代碼來源:MembershipService.cs

示例13: Can_reset_password

 public void Can_reset_password()
 {
     var author = new User {Email = "[email protected]", Password = "1234"};
     userRepository.Expect(x => x.GetAuthorByEmail("[email protected]"))
         .Return(author);
     membershipService.ResetPassword("[email protected]");
     userRepository.AssertWasCalled(x => x.SaveUser(author));
     Assert.AreNotEqual(author.Password, "1234");
 }
開發者ID:DogaOztuzun,項目名稱:BlogSharp,代碼行數:9,代碼來源:MembershipServiceTests.cs

示例14: Connection_Connect_Behaviour_ConnectTwice

        public void Connection_Connect_Behaviour_ConnectTwice()
        {
            User dummy = new User() { Name = "Crash Test Dummy", Password = "Not again!" };
            PieServiceClient pieService = new PieServiceClient();

            pieService.Connect(dummy);
            pieService.Connect(dummy);
            //It's okay for a user to connect twice
        }
開發者ID:Yndal,項目名稱:BDSA-Project-2012,代碼行數:9,代碼來源:PieServiceTest.cs

示例15: AddWeblog

        public static void AddWeblog(User model)
        {
            using (var db = DbBase.CreateDBContext())
               {
               var list = db.GetCollection<User>("users");
               list.Insert(model);

               }
        }
開發者ID:flycd,項目名稱:MyWeb,代碼行數:9,代碼來源:UserService.cs


注:本文中的Model.User類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。