public ResponseMessage Edit(Contact entity) { ResponseMessage response = new ResponseMessage(); _repository.Edit(entity); return(response); }
public void Contact04EditTest() { var Contact = repository.Find(1); Contact.FirstName = "Carlos"; repository.Edit(Contact); Assert.IsTrue(repository.Save()); }
public void Given_ContactRepository_EditContact() { int updateId = 1; ContactEntity entity = objRepo.GetById(updateId); if (entity != null) { entity.FirstName = "TestUpdate"; } objRepo.Edit(entity); databaseContext.SaveChanges(); var result = objRepo.GetById(updateId); Assert.AreEqual(result.FirstName, "TestUpdate"); }
public ActionResult Edit(Contact contact) { if (ModelState.IsValid) { try { _contact.Edit(contact); } catch (Exception ex) { Common.LogError(ModuleType.Edit, ex); } return(RedirectToAction("Index")); } return(View(contact)); }
public ActionResult SaveOrEdit(Contact contact) { try { if (ModelState.IsValid) { if (contact.Id == 0) { contact.State = true; contact.UpdatedDate = DateTime.Now; contact.CreatedDate = DateTime.Now; ContactRepository.Add(contact); } else { contact.UpdatedDate = DateTime.Now; ContactRepository.Edit(contact); } ContactRepository.Save(); if (IsSuperAdmin) { return(RedirectToAction("Index", new { storeId = contact.StoreId })); } else { return(RedirectToAction("Index")); } } } catch (Exception ex) { Logger.Error(ex, "Unable to save:" + ex.StackTrace, contact); //Log the error (uncomment dex variable name and add a line here to write a log. ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists see your system administrator."); } return(View(contact)); }
public ActionResult Edit(ClientTopUnitContactVM clientTopUnitContactVM) { int clientDetailId = clientTopUnitContactVM.ClientDetail.ClientDetailId; ClientDetail clientDetail = new ClientDetail(); clientDetail = clientDetailRepository.GetGroup(clientDetailId); //Check Exists if (clientDetail == null) { ViewData["ActionMethod"] = "EditPost"; return(View("RecordDoesNotExistError")); } ClientDetailClientTopUnit clientDetailClientTopUnit = new ClientDetailClientTopUnit(); clientDetailClientTopUnit = clientDetailClientTopUnitRepository.GetClientDetailClientTopUnit(clientDetailId); //Check Exists if (clientDetailClientTopUnit == null) { ViewData["ActionMethod"] = "EditPost"; return(View("RecordDoesNotExistError")); } string clientTopUnitGuid = clientDetailClientTopUnit.ClientTopUnitGuid; ClientTopUnit clientTopUnit = new ClientTopUnit(); clientTopUnit = clientTopUnitRepository.GetClientTopUnit(clientTopUnitGuid); //Check Exists if (clientTopUnit == null) { ViewData["ActionMethod"] = "EditPost"; return(View("RecordDoesNotExistError")); } //Access Rights RolesRepository rolesRepository = new RolesRepository(); if (!rolesRepository.HasWriteAccessToClientTopUnit(clientTopUnitGuid)) { ViewData["Message"] = "You do not have access to this item"; return(View("Error")); } //Update Model from Form try { TryUpdateModel <Contact>(clientTopUnitContactVM.Contact, "Contact"); } catch { string n = ""; foreach (ModelState modelState in ViewData.ModelState.Values) { foreach (ModelError error in modelState.Errors) { n += error.ErrorMessage; } } ViewData["Message"] = "ValidationError : " + n; return(View("Error")); } try { contactRepository.Edit(clientTopUnitContactVM.Contact); } catch (SqlException ex) { LogRepository logRepository = new LogRepository(); logRepository.LogError(ex.Message); ViewData["Message"] = "There was a problem with your request, please see the log file or contact an administrator for details"; return(View("Error")); } return(RedirectToAction("List", new { id = clientDetailId })); }