Exemple #1
0
        public void AddUser()
        {
            UsersBLL userBLL = new UsersBLL();

            userBLL.CreateUser(userObj);
            User createdUser = userBLL.GetAll().Last();

            Assert.AreEqual(userObj.FirstName, createdUser.FirstName);
            Assert.AreEqual(userObj.LastName, createdUser.LastName);
            Assert.AreEqual(userObj.EmployeeID, createdUser.EmployeeID);
        }
        public async Task <ActionResult <User> > CreateUser(UserViewModel user)
        {
            try
            {
                User newUser = await _usersBll.CreateUser(user);

                return(CreatedAtAction(nameof(GetUser), new { id = newUser.Id }, newUser));
            }
            catch (Exception ex)
            {
                throw new Exception(ex.InnerException.Message);
            }
        }
        public void CreateUser_Benchmark_Performance()
        {
            UsersBLL userBLL = new UsersBLL();

            for (var i = 0; i < 100; i++)
            {
                User userObj = new User();
                userObj.FirstName  = string.Format("{0}{1}", "Valli", i);
                userObj.LastName   = string.Format("{0}{1}", "Subbu", i);
                userObj.EmployeeID = string.Format("{0}{1}", "C", i);
                userBLL.CreateUser(userObj);
            }
        }
Exemple #4
0
        public IActionResult CreateUser(CreateUserModel model)
        {
            try
            {
                CreateUserReq _createUserReq = new CreateUserReq()
                {
                    Name            = model.Name,
                    Surname         = model.Surname,
                    CellPhoneNumber = model.CellPhoneNumber
                };

                return(PartialView("UserGridRow", ControllerHelper.FillUserGridModel(UsersBLL.CreateUser(_createUserReq))));
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemple #5
0
 public ActionResult CreateUser(UserEntity user)
 {
     try
     {
         if (Request.IsAjaxRequest())
         {
             _usersLogic.CreateUser(user);
             return(Json("Usuario creado correctamente"));
         }
         else
         {
             return(RedirectToAction("AccessDenied"));
         }
     }
     catch (Exception exception)
     {
         throw new PersonalizedException(exception.Message);
     }
 }
 public IHttpActionResult Post(User user)
 {
     try
     {
         if (ModelState.IsValid)
         {
             UsersBLL userBLL = new UsersBLL();
             userBLL.CreateUser(user);
             return(Ok());
         }
         else
         {
             return(BadRequest());
         }
     }
     catch (Exception)
     {
         return(InternalServerError());
     }
 }
Exemple #7
0
 public IActionResult Post([FromBody] UserDTO user)
 {
     this.SetPassword(user);
     _usersBLL.CreateUser(user);
     return(StatusCode(201));
 }