public MessageReport DeleteById(string id, ref BM_ApartmentRole obj) { var re = new MessageReport(); re.Message = "Error"; re.isSuccess = false; try { obj = GetById(id); if (obj != null) { obj.IsDeleted = true; _BM_ApartmentRoleRepository.Update(obj); Save(); re.Message = FunctionHelper.GetLocalizeDictionary("Home", "notification")["DeleteSuccess"];; re.isSuccess = true; } else { re.Message = FunctionHelper.GetLocalizeDictionary("Home", "notification")["record_does_not_exist"];; re.isSuccess = false; } } catch (Exception ex) { re.Message = ex.Message; re.isSuccess = false; } return(re); }
/// <summary> /// Xóa /// </summary> /// <modified> /// Author Date Comments /// TrungNQ 18/09/2017 Tạo mới /// </modified> /// <param name="id">Id bản ghi</param> /// <returns></returns> public JsonResult Delete(string id) { var obj = new BM_ApartmentRole(); var result = _BM_ApartmentRoleService.DeleteById(id, ref obj); return(Json(result, JsonRequestBehavior.AllowGet)); }
public ActionResult Create(BM_ApartmentRole obj, string txtFeeLevel = "", string unit = "", string period = "", bool SaveAndCountinue = false) { //Kiểm tra if (!ModelState.IsValid) { return(View(obj)); } // if (string.IsNullOrWhiteSpace(obj.Name)) { ModelState.AddModelError("Name", "Vui lòng nhập tên"); return(View(obj)); } obj.Id = Common.GenerateId(); obj.IsDeleted = false; obj.DateCreated = DateTime.Now; var existed = _BM_ApartmentRoleService.GetByName(obj.Name); if (existed != null) { ModelState.AddModelError("Name", "Thông tin đã tồn tại"); return(View(obj)); } //Thực hiện thêm mới var result = _BM_ApartmentRoleService.Create(obj); if (result.isSuccess) { if (SaveAndCountinue) { TempData["Success"] = result.Message; return(RedirectToAction("Create")); } if (!string.IsNullOrEmpty(url)) { return(Redirect(url)); } else { return(RedirectToAction("Index")); } } else { ModelState.AddModelError("", result.Message); return(View(obj)); } }
public ActionResult Update(BM_ApartmentRole obj, string objId, int pageNumber = 1) { //Danh sách sử dụng //Kiểm tra var oldObj = _BM_ApartmentRoleService.GetById(objId); if (oldObj == null) { ViewBag.Error = "Thông tin không tồn tại"; return(View(obj)); } // if (string.IsNullOrWhiteSpace(obj.Name)) { ModelState.AddModelError("Name", "Vui lòng nhập tên"); return(View(obj)); } var existed = _BM_ApartmentRoleService.GetByName(obj.Name); if (existed != null && existed.Id != objId) { ModelState.AddModelError("Name", "Thông tin đã tồn tại"); return(View(obj)); } //Gán giá trị oldObj.Name = obj.Name; oldObj.Description = obj.Description; //Thực hiện cập nhật var result = _BM_ApartmentRoleService.Update(oldObj); if (result.isSuccess) { if (!string.IsNullOrEmpty(url)) { return(Redirect(url)); } else { return(RedirectToAction("Index")); } } else { ModelState.AddModelError("", result.Message); return(View(oldObj)); } }
public MessageReport Create(BM_ApartmentRole obj) { var re = new MessageReport(); re.Message = "Error"; re.isSuccess = false; try { _BM_ApartmentRoleRepository.Add(obj); Save(); re.Message = FunctionHelper.GetLocalizeDictionary("Home", "notification")["addSuccess"]; re.isSuccess = true; } catch (Exception ex) { re.Message = ex.Message; re.isSuccess = false; } return(re); }