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

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

            try
            {
                obj = GetById(Convert.ToInt32(id));
                if (obj != null)
                {
                    _BM_ApartmentEWPriceRepository.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);
        }
Exemplo n.º 2
0
        public ActionResult Index(string group = "")
        {
            ViewBag.GroupID = group;

            var obj = _BM_ApartmentEWPriceService.GetDefault();

            if (obj == null)
            {
                obj    = new BM_ApartmentEWPrice();
                obj.Id = Common.GenerateId();
                obj.Electricity_Price = 0;
                obj.Water_Price       = 0;
                obj.DateCreated       = DateTime.Now;
                obj.IsDeleted         = false;
                obj.Date_Price        = DateTime.Now;

                _BM_ApartmentEWPriceService.Create(obj);
            }

            return(View(obj));
        }
Exemplo n.º 3
0
        public ActionResult Index(BM_ApartmentEWPrice obj, string txtWPrice, string txtEPrice, string dtpDate, string group = "")
        {
            ViewBag.GroupID = group;

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

            var oldObj = _BM_ApartmentEWPriceService.GetDefault();

            if (oldObj == null)
            {
                oldObj = new BM_ApartmentEWPrice();

                _BM_ApartmentEWPriceService.Create(oldObj);
            }

            //Gán
            oldObj.Electricity_Price = !string.IsNullOrEmpty(txtEPrice) ? Convert.ToDecimal(txtEPrice.Replace(",", "").Replace(".", "")) : 0;
            oldObj.Water_Price       = !string.IsNullOrEmpty(txtWPrice) ? Convert.ToDecimal(txtWPrice.Replace(",", "").Replace(".", "")) : 0;
            oldObj.Date_Price        = !string.IsNullOrEmpty(dtpDate) ? Convert.ToDateTime(dtpDate) : DateTime.Now;

            var result = _BM_ApartmentEWPriceService.Update(oldObj);

            if (result.isSuccess)
            {
                var host = Request.Url.Host;
                Session[string.Format("{0}_{1}", SessionConfig.SystemConfigSession, host)] = null;

                TempData["Success"] = result.Message;
                return(View(oldObj));
            }
            else
            {
                ModelState.AddModelError("", result.Message);
                return(View(obj));
            }
        }
        public MessageReport Create(BM_ApartmentEWPrice obj)
        {
            var re = new MessageReport();

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

            try
            {
                _BM_ApartmentEWPriceRepository.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);
        }