public IActionResult Create([Bind("UserId,Username,Password,Email,ProfileId")] InsertNewUser user) { if (ModelState.IsValid) { _unitOfWork.UsersRepository.InsertUser(user); return(RedirectToAction(nameof(Index))); } ViewData["ProfileId"] = new SelectList(_unitOfWork.ProfilesRepository.GetAllProfiles(), "ProfileId", "Name", user.ProfileId); return(View(user)); }
public void InsertUser(InsertNewUser entity) { try { _unitOfWork.UsersRepository.InsertUser(entity); } catch (Exception ex) { throw ex; } }
public void InsertUser(InsertNewUser entity) { Users userToSave = new Users() { Username = entity.Username, Password = entity.Password, Email = entity.Email, ProfileId = entity.ProfileId }; this._DbContext.Users.Add(userToSave); this._DbContext.SaveChanges(); }