public static DboUsers ToDboUser(this UserDTO user) { DboUsers dboUser = new DboUsers(); if (user != null) { dboUser.name = user.UserName; dboUser.email = user.UserEmail; } return(dboUser); }
public static UserDTO ToUserDTO(this DboUsers user) { UserDTO userDTO = new UserDTO(); if (user != null) { userDTO.UserId = user.userId; userDTO.UserName = user.name; userDTO.UserEmail = user.email; } return(userDTO); }
public IHttpActionResult CreatUser(UserDTO userToCreate) { using (IUnitOfWork dbTask = new UnitOfWork()) { DboUsers newUser = userToCreate.ToDboUser(); newUser = dbTask.DataRepo.CreateNewUser(newUser); List <Problem> errors = new List <Problem>(); if (!newUser.Validate(errors)) { var response = Request.CreateResponse(HttpStatusCode.BadRequest, errors); return(ResponseMessage(response)); } dbTask.SaveChanges(); return(Ok(newUser.ToUserDTO())); } }
public DboUsers CreateNewUser(DboUsers user) { var newUser = Context.users.Add(user); return(newUser); }