public ParkVM GetVendors(string id) { int?managerId = _db.Users.Where(u => u.Id == id).FirstOrDefault().ManagerInfoId; ParkVM vm = null; List <VendorVM> vendors = null; if (managerId != null) { vendors = _db.RestaurantManagers.OrderBy(rm => rm.Restaurant.Name).Where(rm => rm.ManagerInfoId == managerId && !rm.IsRetired).Select(v => new VendorVM { Id = v.Restaurant.Id, Name = v.Restaurant.Name, Description = v.Restaurant.Description, Categories = v.Restaurant.Categories.OrderBy(c => c.Name).Where(c => !c.IsRetired).Select(c => new CategoryVM { Id = c.Id, Name = c.Name, Items = c.Items.OrderBy(i => i.Name).Where(i => !i.IsRetired).Select(i => new ItemVM { Id = i.Id, Name = i.Name, ImageUrl = i.ImageUrl, Price = i.Price, IsAlcohol = i.IsAlcohol }).ToList() }).ToList() }).ToList(); vm = _db.Parks.Select(p => new ParkVM { Id = p.Id, Name = p.Name, LogoUrl = p.LogoUrl, TaxRate = p.TaxRate }).FirstOrDefault(); vm.Vendors = vendors; } return(vm); }
public ParkVM GetPark() { ParkVM vm = _db.Parks.Select(p => new ParkVM { Id = p.Id, Name = p.Name, LogoUrl = p.LogoUrl, TaxRate = p.TaxRate, Areas = p.Areas.Where(a => !a.IsRetired).OrderBy(a => a.Name).Select(a => new AreaVM { Id = a.Id, Name = a.Name, Vendors = a.Restaurants.Where(r => !r.IsRetired).OrderBy(r => r.Name).Select(r => new VendorVM { Id = r.Id, Name = r.Name, Description = r.Description, Categories = r.Categories.Where(c => !c.IsRetired).OrderBy(c => c.Name).Select(c => new CategoryVM { Id = c.Id, Name = c.Name, Items = c.Items.Where(i => !i.IsRetired).OrderBy(i => i.Name).Select(i => new ItemVM { Id = i.Id, Name = i.Name, ImageUrl = i.ImageUrl, Description = i.Description, Price = i.Price, Discount = i.Discount, //Views = i.Views.Count, //Purchases = i.Purchases.Count, IsAlcohol = i.IsAlcohol }).ToList() }).ToList() }).ToList() }).ToList() }).FirstOrDefault(); return(vm); }
public IActionResult Detail(string parkCode, string unitPref) { if (unitPref == null) { string sessionString = HttpContext.Session.GetString("UnitPref"); unitPref = sessionString == null ? "F" : sessionString; } else { HttpContext.Session.SetString("UnitPref", unitPref); } Park park = new Park(); park = parkDAO.GetParksByCode(parkCode); IList <Weather> weather; weather = weatherSQLDAO.GetWeather(parkCode); ParkVM parkView = new ParkVM(park, weather); parkView.UnitPref = unitPref; return(View(parkView)); }