Exemplo n.º 1
0
        public ActionResult AddPriceToCategory(AddPriceViewModel prices)
        {
            //TODO: Sätta en maxgräns för hur många dagar man kan spara pris för. ?
            if (!ModelState.IsValid) return View(prices);

            categoryService.AddOrUpdateCategoryPrice(prices.CategoryId, prices.Price, prices.FirstDay, prices.LastDay);
            return RedirectToAction("Category", new { id = prices.CategoryId });
        }
Exemplo n.º 2
0
        public ActionResult AddPriceToCategory(int id,string date)
        {
            DateTime dtDate;
            bool dateValid = DateTime.TryParse(date, out dtDate);
            dtDate = dateValid ? dtDate : DateTime.Now;

            Service.DTO.CategoryModel categoryModel = categoryService.GetById(id);
            AddPriceViewModel addPriceModel = new AddPriceViewModel() { CategoryId = id, FirstDay = dtDate, LastDay = dtDate,Price=0 };
            if (categoryModel.PricePerDay.Any(m => m.CheckinDate.Date == dtDate.Date))
                addPriceModel.Price = categoryModel.PricePerDay.First(m => m.CheckinDate.Date == dtDate.Date).Price;

            return View(addPriceModel);
        }