public MessageReport DeleteById(string id, ref BM_ApartmentUse obj)
        {
            var re = new MessageReport();

            re.Message   = "Error";
            re.isSuccess = false;

            try
            {
                obj = GetById(id);
                if (obj != null)
                {
                    _BM_ApartmentUseRepository.Delete(n => n.Id.ToString() == id);

                    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);
        }
        public JsonResult Delete(string id)
        {
            var obj = new BM_ApartmentUse();

            var result = _BM_ApartmentUseService.DeleteById(id, ref obj);

            if (result.isSuccess)
            {
                WriteLog.Write(result, GetCurrentUser.GetUser(), obj.Id.ToString(), obj.Name, "BM_ApartmentUse", ConstField.ResidentCode, ActionConfigO.Delete);
            }

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
        public ActionResult Update(BM_ApartmentUse obj, string key = "", int page = 1)
        {
            ViewBag.keyValue = key;
            ViewBag.PN       = page;

            //Kiểm tra
            var oldObj = _BM_ApartmentUseService.GetById(obj.Id);

            if (oldObj == null)
            {
                ViewBag.Error = "Bản ghi không tồn tại";
                return(View(obj));
            }

            if (!ModelState.IsValid)
            {
                return(View(oldObj));
            }

            //Gán giá trị
            oldObj.Name     = obj.Name;
            oldObj.Ordering = obj.Ordering;

            //Thực hiện cập nhật
            var result = _BM_ApartmentUseService.Update(oldObj);

            if (result.isSuccess)
            {
                WriteLog.Write(result, GetCurrentUser.GetUser(), obj.Id.ToString(), obj.Name, "BM_ApartmentUse", ConstField.ResidentCode, ActionConfigO.Update);

                return(RedirectToAction("Index", new { page = page, key = key }));
            }
            else
            {
                ModelState.AddModelError("", result.Message);
                return(View(oldObj));
            }
        }
        public MessageReport Create(BM_ApartmentUse obj)
        {
            var re = new MessageReport();

            re.Message   = "Error";
            re.isSuccess = false;

            try
            {
                _BM_ApartmentUseRepository.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);
        }
        public ActionResult Create(BM_ApartmentUse obj, bool SaveAndCountinue = false, string key = "")
        {
            ViewBag.keyValue = key;

            //Kiểm tra
            if (!ModelState.IsValid)
            {
                return(View(obj));
            }


            //Gán giá trị
            obj.Id          = Guid.NewGuid().ToString();
            obj.DateCreated = DateTime.UtcNow;

            //Thực hiện thêm mới
            var result = _BM_ApartmentUseService.Create(obj);

            if (result.isSuccess)
            {
                WriteLog.Write(result, GetCurrentUser.GetUser(), obj.Id.ToString(), obj.Name, "BM_ApartmentUse", ConstField.ResidentCode, ActionConfigO.Create);

                if (SaveAndCountinue)
                {
                    TempData["Success"] = result.Message;
                    return(RedirectToAction("Create", new { key = key }));
                }

                return(RedirectToAction("Index", new { key = key }));
            }
            else
            {
                ModelState.AddModelError("", result.Message);
                return(View(obj));
            }
        }