Пример #1
0
 public ActionResult Create(Models.CreateUser info)
 {
     try
     {
         //using (BusinessLogicLayer.ContextBLL ctx = new BusinessLogicLayer.ContextBLL())
         //{
         if (!ModelState.IsValid)
         {
             return(View(info));
         }
         using (BusinessLogicLayer.ContextBLL ctx = new BusinessLogicLayer.ContextBLL())
         {
             BusinessLogicLayer.UserBLL user = ctx.FindUserByUserName(info.UserName);
             //if (user != null)
             //{
             //    info.Message = $"The EMail Address '{info.Email}' already exists in the database";
             //    return View(info);
             //}
             user             = new UserBLL();
             user.FirstName   = info.FirstName;
             user.LastName    = info.LastName;
             user.UserName    = info.UserName;
             user.DateOfBirth = info.DateOfBirth;
             user.RoleID      = info.RoleID;
             user.SALT        = System.Web.Helpers.Crypto.
                                GenerateSalt(Constants.SaltSize);
             user.HASH = System.Web.Helpers.Crypto.
                         HashPassword(info.Password + user.SALT);
             user.Email = info.Email;
             ctx.CreateUser(user);
             Session["AUTHUserName"] = user.UserName;
             Session["AUTHRoles"]    = user.RoleName;
             Session["AUTHTYPE"]     = "HASHED";
         }
         return(RedirectToAction("Index"));
     }
     catch (Exception Ex)
     {
         ViewBag.Exception = Ex;
         return(View("Error"));
     }
 }
Пример #2
0
        public bool CreateNewUser(string UserId, string Password, string FirstName, string LastName, string Email, string Mobile, string Gender, int UserType)
        {
            bool       success = false;
            CreateUser req     = new Models.CreateUser();

            req.EmailId   = Email;
            req.FirstName = FirstName;
            req.LastName  = LastName;
            req.UserId    = UserId;
            req.Password  = Password;
            req.MobileNo  = Mobile;
            req.userType  = UserType;
            req.Gender    = Gender;
            var result = ServerBAL.CreateNewUser(req);

            if (result != null)
            {
                return(result.UserId != null);
            }
            return(success);
        }