public ActionResult Edit(int id, FormCollection collection) { Models.CorporationModel corp = null; try { corp = new Models.CorporationModel { CorporationId = collection.Get("CorporationId"), Name = collection.Get("Name"), Address = collection.Get("Address"), Phone = collection.Get("Phone"), }; if (_corporationService.UpdateCorporation(corp)) { return(View("Index", _corporationService.GetCorporationList())); } else { ModelState.AddModelError(string.Empty, _corporationService.ErrorDescription); throw new Exception(); } } catch { ViewBag.IsNew = false; return(View("Create", corp)); } }
public async Task <ActionResult> Create(FormCollection collection) { Models.CorporationModel corp = null; try { // TODO: Add insert logic here corp = new Models.CorporationModel { CorporationId = collection.Get("CorporationId"), Name = collection.Get("Name"), Address = collection.Get("Address"), Phone = collection.Get("Phone"), }; if (await _corporationService.AddCorporation(corp)) { return(View("Index", _corporationService.GetCorporationList())); } else { ModelState.AddModelError(string.Empty, _corporationService.ErrorDescription); throw new Exception(); } } catch { ViewBag.IsNew = true; return(View(corp)); } }
private void ExecuteSaveAndClose(object parameter) { IMessageBoxService _msgboxcommand = new MessageBoxService(); if (!IsValidCorporationName(_corporationname)) { _msgboxcommand.ShowMessage("Corporation Name is invalid", "Corporation Name Error", GenericMessageBoxButton.OK, GenericMessageBoxIcon.Error); } else { Models.CorporationModel _newcorp = new Models.CorporationModel(); _newcorp.GOM.Name = _corporationname; DatabaseQueries.AddNewCorporation(_newcorp); CloseWindow(); } }
// GET: Corporations/Edit/5 public ActionResult Edit(string id) { ViewBag.IsNew = false; Models.CorporationModel corp = _corporationService.GetCorporation(id); return(View("Create", corp)); }