public void GetUsersTest() { UserCRUD userService = new UserCRUD(new TestDataRepository()); userService.AddUser(16, "Wartłomiej", "Błodarski"); userService.AddUser(19, "Kaciej", "Mopa"); userService.AddUser(22, "Wartłomiej", "Bubicki"); IEnumerable <UserDTO> users = userService.GetAllUsers(); Assert.AreEqual(users.Count(), 3); userService.DeleteUser(16); userService.DeleteUser(19); userService.DeleteUser(22); }
public void AddUserTest() { UserCRUD userService = new UserCRUD(new TestDataRepository()); Assert.IsTrue(userService.AddUser(67, "Jan", "Paweł the second")); Assert.IsTrue(userService.DeleteUser(67)); }
public void GetUserTest() { UserCRUD userService = new UserCRUD(new TestDataRepository()); userService.AddUser(88, "Chloe", "Price"); Assert.AreEqual(userService.GetUser(88).FirstName, "Chloe"); userService.DeleteUser(88); }
public ActionResult Crear(User modelo, HttpPostedFileBase file, bool IsAdmin = false) { string path = ""; if (file != null) { string pic = Path.GetFileName(file.FileName); path = Path.Combine( Server.MapPath("~/Style/Media/User_Images"), pic); file.SaveAs(path); using (MemoryStream ms = new MemoryStream()) { file.InputStream.CopyTo(ms); byte[] array = ms.GetBuffer(); } } operations.AddUser(modelo, IsAdmin, path); ModelState.Clear(); return(View("CrearUsuario")); }
public void UpdateUserTest() { UserCRUD userService = new UserCRUD(new TestDataRepository()); userService.AddUser(11, "Max", "Verstappen"); Assert.IsTrue(userService.UpdateLastName(11, "Caulfield")); Assert.AreEqual(userService.GetUser(11).LastName, "Caulfield"); Assert.IsTrue(userService.UpdateFirstName(11, "Timothy")); Assert.AreEqual(userService.GetUser(11).FirstName, "Timothy"); userService.DeleteUser(11); }
public BaseResponse AddUser(UserCR req) { BaseResponse resp = new BaseResponse(); try { if (ValidateRequest.AddUser(req)) { UserCRUD userCRUD = new UserCRUD(); if (!userCRUD.IsUserEmailExists(req.User.email_id)) { req.User.last_update = DateTime.Now; if (userCRUD.AddUser(req.User) > 0) { resp.StatusCode = HttpStatusCode.OK; resp.StatusMessage = HttpStatusCode.OK.ToString(); } else { resp.StatusCode = HttpStatusCode.Ambiguous; resp.StatusMessage = HttpStatusCode.Ambiguous.ToString(); } } else { resp.StatusCode = HttpStatusCode.Conflict; resp.StatusMessage = HttpStatusCode.Conflict.ToString(); } } else { resp.StatusCode = HttpStatusCode.BadRequest; resp.StatusMessage = HttpStatusCode.BadRequest.ToString(); } } catch (Exception es) { resp.StatusCode = HttpStatusCode.InternalServerError; resp.StatusMessage = HttpStatusCode.InternalServerError.ToString(); } return(resp); }
private void AddUser() { _Service.AddUser(FirstName, LastName); GetUsers(); }
public void AddUsers(User user) { UserCRUD userCrud = new UserCRUD(); userCrud.AddUser(user); }