AddUser() public method

public AddUser ( User u ) : User
u User
return User
コード例 #1
0
        public ActionResult Registration(Models.Registartion r)
        {
            if (ModelState.IsValid)
            {
                using (DBBL DB = new DBBL())
                {
                    //check postojeceg usera
                    Igman.DB.DAL.User u;

                    u = DB.GetUserByEmail(r.Email);
                    if (u != null)
                    {
                        TempData["ExistUser"] = u;
                        return RedirectToAction("index", "wellcome");
                    }
                    u = new Igman.DB.DAL.User();

                    u.FirstName = r.FirstName;
                    u.LastName = r.LastName;

                    u.LoweredEmail = r.Email.ToLower();
                    u.Email = r.Email;

                    u.Password = r.Password;
                    u.GUID = Guid.NewGuid();

                    u.IsApproved = true;
                    u.LastLogin = DateTime.Now;

                    u.Roles.Add(DB.GetRoleByID(2)); // User (2)

                    u = DB.AddUser(u);
                    Autorizacija.Autorizacija.AddUserLogin(u, this.HttpContext);
                }
            }
            return RedirectToAction("index", "wellcome");
        }