public ActionResult Delete_Confirm(int id) { var strError = string.Empty; if (id <= 0) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } try { _mainStore.Delete(id); //Clear cache CachingHelpers.ClearUnitCache(); } catch (Exception ex) { strError = ManagerResource.LB_SYSTEM_BUSY; logger.Error("Failed to get Delete Unit because: " + ex.ToString()); return(Json(new { success = false, message = strError })); } return(Json(new { success = true, message = ManagerResource.LB_DELETE_SUCCESS, title = ManagerResource.LB_NOTIFICATION })); }
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 Edit(UnitEditModel model) { 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 data var info = ExtractEditFormData(model); var isSuccess = _mainStore.Update(info); //Clear cache CachingHelpers.ClearUnitCache(); if (isSuccess) { this.AddNotification(ManagerResource.LB_UPDATE_SUCCESS, NotificationType.SUCCESS); } } catch (Exception ex) { this.AddNotification(NotifSettings.Error_SystemBusy, NotificationType.ERROR); logger.Error("Failed for Edit Unit request: " + ex.ToString()); return(View(model)); } return(RedirectToAction("Edit/" + model.Id)); }