Exemplo n.º 1
0
 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));
 }
Exemplo n.º 2
0
 public void InsertUser(InsertNewUser entity)
 {
     try
     {
         _unitOfWork.UsersRepository.InsertUser(entity);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 3
0
        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();
        }