public ActionResult CreateUser(string username, string password) { User user = db.Users.FirstOrDefault(u => u.UserName == username); if (ModelState.IsValid) { if (user == null) { db.Users.Add(new User { UserName = username, Password = password }); db.SaveChanges(); User newUser = db.Users.FirstOrDefault(u => u.UserName == username); Session["UserID"] = newUser.UserID; } else { //this username already exists } } return(RedirectToAction("UserProfile")); }
public IHttpActionResult CreateProfile(InsertModel insertModel) { pCDBContext.AddProfileContact(insertModel.ProfileId, insertModel.Firstname, insertModel.Lastname, insertModel.DOB, insertModel.ContactId, insertModel.ContactType, insertModel.ContactNumber); pCDBContext.SaveChanges(); return(Ok()); }