public ActionResult Edit([Bind(Include = "")] AdapterBasicDTO adapterBasicDTO) { #region For keeping note //1. way var adapterNameRequest = Request.Form["AdapterName"]; //2. way FormCollection values = null; var adapterNameFormCollection = values["AdapterName"]; //Parameter : FormCollection values #endregion //TODO : there may be AdapterType with id : 0 //TODO : How to validate AdapterTypeId ??? //TODO : How to catch ModelState.Error if (adapterBasicDTO.AdapterTypeId <= 0) { ViewData.ModelState.AddModelError("AdapterTypeId", new ArgumentNullException("AdapterTypeId", "Please select an adapter type.")); } if (ModelState.IsValid) { using (UoW) { _repo.Update(adapterBasicDTO); } return(RedirectToAction("Index")); } SetAdapterType(); return(RedirectToAction("Edit", new { id = adapterBasicDTO.Id, saveChangesError = true })); }
public ActionResult Edit([Bind(Include = "")] AdapterTypeViewModel adapterType) { if (ModelState.IsValid) { using (UoW) { _repo.Update(new AdapterTypeDIMDTO() { Id = adapterType.Id, AdapterType = adapterType.AdapterType }); return(RedirectToAction("Index")); } } return(RedirectToAction("Edit", new { id = adapterType.Id, saveError = true })); }
public ActionResult Edit([Bind(Include = "")] AdapterBasicViewModel adapter) { #region For keeping note ////1. way //var adapterNameRequest = Request.Form["AdapterName"]; ////2. way //FormCollection values = null; //TODO : this needs to come as parameter //var adapterNameFormCollection = values["AdapterName"]; //Parameter : FormCollection values #endregion //TODO : there may be AdapterType with id : 0 //TODO : How to validate AdapterTypeId ??? //TODO : How to catch ModelState.Error if (adapter.AdapterTypeId <= 0) { ViewData.ModelState.AddModelError("AdapterTypeId", new ArgumentNullException("AdapterTypeId", "Please select an adapter type.")); } if (ModelState.IsValid) { using (UoW) { _repo.Update(new AdapterBasicDTO() { Id = adapter.Id, AdapterName = adapter.AdapterName, AdapterTypeId = adapter.AdapterTypeId, IsActive = adapter.IsActive, ModifiedDate = adapter.ModifiedDate, RegistrationDate = adapter.RegistrationDate, }); } return(RedirectToAction("Index")); } return(RedirectToAction("Edit", new { id = adapter.Id, saveChangesError = true })); }