private IdentityUnit ExtractCreateFormData(UnitCreateModel formData) { var myIdetity = new IdentityUnit(); myIdetity.Name = formData.Name; myIdetity.Code = formData.Code; myIdetity.Status = formData.Status; return(myIdetity); }
public ActionResult Create(UnitCreateModel model) { var newId = 0; if (!ModelState.IsValid) { string messages = string.Join("; ", ModelState.Values .SelectMany(x => x.Errors) .Select(x => x.ErrorMessage + x.Exception)); this.AddNotification(messages, NotificationType.ERROR); return(View(model)); } try { //Extract info var info = ExtractCreateFormData(model); newId = _mainStore.Insert(info); //Clear cache CachingHelpers.ClearUnitCache(); if (newId > 0) { this.AddNotification(ManagerResource.LB_INSERT_SUCCESS, NotificationType.SUCCESS); } else { this.AddNotification(NotifSettings.Error_SystemBusy, NotificationType.ERROR); } } catch (Exception ex) { this.AddNotification(NotifSettings.Error_SystemBusy, NotificationType.ERROR); logger.Error("Failed for Create Unit request: " + ex.ToString()); return(View(model)); } return(RedirectToAction("Edit/" + newId)); }
public ActionResult Create() { var createModel = new UnitCreateModel(); return(View(createModel)); }