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 })); }
private AdapterBasicDTO InsertAdapter(AdapterBasicDTO adapterBasicDTO) { adapterBasicDTO.Id = Adapters.Count; Adapters.Add(adapterBasicDTO); return(adapterBasicDTO); }
public ActionResult Create([Bind(Include = "")] AdapterBasicDTO adapterBasicDTO) { if (ModelState.IsValid) { using (UoW) { _repo.Insert(adapterBasicDTO); } return(RedirectToAction("Index")); } SetAdapterType(); return(View(adapterBasicDTO)); }
private AdapterBasicDTO UpdateAdapter(AdapterBasicDTO adapterBasicDTO) { var adapter = Adapters.FirstOrDefault(x => x.Id == adapterBasicDTO.Id); if (adapter == null) { return(null); } Adapters.Remove(adapter); Adapters.Add(adapterBasicDTO); return(adapterBasicDTO); }