当前位置: 首页>>代码示例>>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;未经允许,请勿转载。