コード例 #1
0
        public bool UpdateTu_SoLuongHienTai(string id, ActionWithObject action)
        {
            int soluong = 0;
            var tu      = _tuService.GetById(id);

            if (tu == null)
            {
                return(false);
            }

            soluong = Compute.ComputeAmountWithAction(tu.SoLuongHienTai, action);

            if (soluong > tu.SoLuongMax)
            {
                ViewBag.Tus = SelectListItemFromDomain.SelectListItem_Tu(_tuService.GetAll(m => m.OrderBy(t => t.Ten)));
                return(false);
            }
            else
            {
                tu.SoLuongHienTai = soluong;

                _tuService.Update(tu);
                return(true);
            }
        }
コード例 #2
0
        public bool UpdateTu_SoHopHienTai(string id, ActionWithObject action)
        {
            var ke = _keService.GetById(id);

            if (ke == null)
            {
                return(false);
            }

            var soluong = Compute.ComputeAmountWithAction(ke.SoHopHienTai, action);

            if (soluong > ke.SoHopToiDa)
            {
                DropDownList();
                return(false);
            }
            else
            {
                ke.SoHopHienTai = soluong;
                _keService.Update(ke);
                return(true);
            }
        }