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.ClearPropertyCategoryCache(); } catch (Exception ex) { strError = ManagerResource.LB_SYSTEM_BUSY; logger.Error("Failed to get Delete PropertyCategory 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(PropertyCategoryCreateModel 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.ClearPropertyCategoryCache(); 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 PropertyCategory request: " + ex.ToString()); return(View(model)); } return(RedirectToAction("Edit/" + newId)); }
public ActionResult Edit(PropertyCategoryEditModel 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.ClearPropertyCategoryCache(); 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 PropertyCategory request: " + ex.ToString()); return(View(model)); } return(RedirectToAction("Edit/" + model.Id)); }
public ActionResult UpdateProperty(PropertyEditModel model) { var msg = ManagerResource.LB_OPERATION_SUCCESS; var isSuccess = false; 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(Json(new { success = isSuccess, title = ManagerResource.LB_NOTIFICATION, message = messages })); } try { //Begin db transaction var data = new IdentityProperty(); data.PropertyCategoryId = model.PropertyCategoryId; data.Id = model.Id; data.Code = model.Code; data.Name = model.Name; data.Status = (int)EnumStatus.Activated; var storeProperty = GlobalContainer.IocContainer.Resolve <IStoreProperty>(); if (model.Id > 0) { //Update storeProperty.Update(data); //Clear cache CachingHelpers.ClearPropertyCategoryCache(); } else { //Add new var newId = storeProperty.Insert(data); if (newId > 0) { isSuccess = true; //Clear cache CachingHelpers.ClearPropertyCategoryCache(); return(Json(new { success = isSuccess, title = ManagerResource.LB_NOTIFICATION, message = ManagerResource.LB_OPERATION_SUCCESS, clientcallback = " location.reload()" })); } } isSuccess = true; } catch (Exception ex) { this.AddNotification(NotifSettings.Error_SystemBusy, NotificationType.ERROR); logger.Error("Failed for UpdateProperty request: " + ex.ToString()); return(Json(new { success = isSuccess, title = ManagerResource.LB_NOTIFICATION, message = NotifSettings.Error_SystemBusy })); } return(Json(new { success = isSuccess, title = ManagerResource.LB_NOTIFICATION, message = msg, clientcallback = " location.reload()" })); }