public string GetListB(long roomTypeId)
        {
            var models = DisposableMaterialBll.GetList(UserContext.CurrentUser.HotelId);

            models = models.Where(a => !a.IsChangeEveryday).ToList();

            LoadQuantity(models, roomTypeId);
            return(JsonConvert.SerializeObject(models));
        }
        public ActionResult Edit(long id = 0)
        {
            if (id == 0)
            {
                return(View(new DisposableMaterial()));
            }
            var info = DisposableMaterialBll.GetById(id);

            return(View(info));
        }
        private void LoadRoomQuantity(List <DisposableMaterial> list, long roomId)
        {
            var settting = DisposableMaterialBll.GetRoomSetting(roomId);

            foreach (var item in list)
            {
                var o = settting.Where(a => a.MaterialId == item.Id).FirstOrDefault();
                item.RoomQuantity = o == null ? item.Quantity : o.Number;
            }
        }
        public ActionResult Delete(long id)
        {
            var apiResult = new APIResult();

            try
            {
                DisposableMaterialBll.DeleteById(id);
            }
            catch (Exception ex)
            {
                apiResult.Ret = -1;
                apiResult.Msg = ex.Message;
                if (!(ex is OperationExceptionFacade))
                {
                    LogFactory.GetLogger().Log(LogLevel.Error, ex);
                }
            }
            return(Json(apiResult));
        }
        public JsonResult Edit(DisposableMaterial model)
        {
            var apiResult = new APIResult();

            try
            {
                DisposableMaterialBll.AddOrUpdate(model, UserContext.CurrentUser.HotelId);
            }
            catch (Exception ex)
            {
                apiResult.Ret = -1;
                apiResult.Msg = ex.Message;
                if (!(ex is OperationExceptionFacade))
                {
                    LogFactory.GetLogger().Log(LogLevel.Error, ex);
                }
            }

            return(Json(apiResult));
        }
        public JsonResult SaveQuantity(string dataJson, long roomTypeId)
        {
            var apiResult = new APIResult();

            try
            {
                var data = new System.Web.Script.Serialization.JavaScriptSerializer().Deserialize <List <DisposableMaterial> >(dataJson);

                DisposableMaterialBll.SaveQuantity(data, roomTypeId);
            }
            catch (Exception ex)
            {
                apiResult.Ret = -1;
                apiResult.Msg = ex.Message;
                if (!(ex is OperationExceptionFacade))
                {
                    LogFactory.GetLogger().Log(LogLevel.Error, ex);
                }
            }

            return(Json(apiResult));
        }
        public string GetList()
        {
            var models = DisposableMaterialBll.GetList(UserContext.CurrentUser.HotelId);

            return(JsonConvert.SerializeObject(models));
        }