public ActionResult SignUp(UserViewModel_Signup u) { if (ModelState.IsValid) { User usr = signUp.SignUp(u); return(Redirect(Url.Action("index", "home"))); } else { ModelState.AddModelError("", "Already registered user or invalid data entry. Try again."); return(View("")); } }
public static Customer ToDomainModel(this UserViewModel_Signup cust) { //This function adds A customer TO Customer table in the Database Customer Cst = new Customer(); Cst.LastName = cust.LastName; Cst.MiddleInitial = cust.MiddleInitial; Cst.FirstName = cust.FirstName; Cst.houseNo = cust.houseNo; Cst.SubCity = cust.SubCity; Cst.City = cust.City; Cst.DateOfBirth = cust.DOB; Cst.email = cust.email; Cst.PasswordHashed = cust.Password;// needs some improvements to include password hashing return(Cst); }
public User SignUp(UserViewModel_Signup u) { var us = bDb.Customer.Where(c1 => c1.email == u.email).FirstOrDefault(); if (us == null) { Customer cust = new Customer(); cust = CustomerMapper.ToDomainModel(u); bDb.Customer.Add(cust); User usr = new User(); usr.Email = u.email; usr.Password = u.Password; bDb.User.Add(usr); bDb.SaveChanges(); return(usr); } else { return(null); } }