protected void SavePassClick(object sender, EventArgs e) { int dayPass = int.Parse(HidPass.Value); int cabanaPass = int.Parse(HidCabana.Value); int spaPass = int.Parse(HidSpaPass.Value); int dayBedPass = int.Parse(HidDayBed.Value); var passLimit = new DailyPassLimit { HotelId = _hotels.HotelId, DailyPass = dayPass, CabanaPass = cabanaPass, SpaPass = spaPass, DaybedPass = dayBedPass }; // TODO: didn't allow to compile //_hotelRepository.UpdateDailyPassLimit(passLimit, ""); if (RptAddOns.Items.Count > 0) { var listProducts = new List <Products>(); foreach (RepeaterItem item in RptAddOns.Items) { //to get the dropdown of each line HiddenField productIdHid = (HiddenField)item.FindControl("HidId"); var product = _productRepository.GetById(int.Parse(productIdHid.Value)); var dailySalesHid = (HiddenField)item.FindControl("HidDailySales"); product.PassCapacity = 1; if (!string.IsNullOrEmpty(dailySalesHid.Value)) { product.PassCapacity = int.Parse(dailySalesHid.Value); } listProducts.Add(product); } // TODO didn't allow to compile //_productRepository.Update(listProducts); } _hotelRepository.ResetCache(); ReloadPass(true); CurrentPass.Text = dayPass.ToString(); saving.InnerText = "Saved!"; saving.Attributes["class"] = "saving"; ClientScript.RegisterClientScriptBlock(GetType(), "hideSaved", "setTimeout(function(){ $('.saving').animate({ opacity: 0 }, 1400, function () { });}, 100);", true); }
public DailyPassLimit GetDailyPassLimit(int hotelId) { var hotels = GetAll().FirstOrDefault(h => h.HotelId == hotelId); if (hotels == null) { return(new DailyPassLimit { HotelId = hotelId }); } var products = ProductList.Where(p => p.HotelId == hotelId && p.IsActive && !p.IsDelete).ToList(); var passLimit = new DailyPassLimit { HotelId = hotelId, DailyPass = products.Where(h => h.ProductType == (int)Enums.ProductType.DayPass).DefaultIfEmpty().Max(h => h != null ? h.PassCapacity : 0), CabanaPass = products.Where(h => h.ProductType == (int)Enums.ProductType.Cabana).DefaultIfEmpty().Max(h => h != null ? h.PassCapacity : 0), SpaPass = products.Where(h => h.ProductType == (int)Enums.ProductType.SpaPass).DefaultIfEmpty().Max(h => h != null ? h.PassCapacity : 0), DaybedPass = products.Where(h => h.ProductType == (int)Enums.ProductType.Daybed).DefaultIfEmpty().Max(h => h != null ? h.PassCapacity : 0) }; return(passLimit); }