public List <ShoppingBasketResponse> ShoppingList(ShoppingListRequest shoppingListRequest) { using (DataAccess dataAccess = new DataAccess()) { var list = from s in dataAccess.ShoppingBasket join product in dataAccess.Products on s.ProductID equals product.ProductID join category in dataAccess.Categories on product.CategoryID equals category.CategoryID join unit in dataAccess.Unit on product.UnitID equals unit.UnitID join seller in dataAccess.Sellers on product.SellerID equals seller.SellerID join city in dataAccess.Cities on seller.CityID equals city.CityID where s.CustomerID == shoppingListRequest.CustomerID orderby s.ShoppingBasketID descending select new ShoppingBasketResponse { ID = s.ShoppingBasketID, CategoryName = category.CategoryName, ProductCode = product.ProductCode, ProductName = product.ProductName, Volume = product.Volume, UnitName = unit.UnitName, SellerName = seller.Name, SellerSurame = seller.Surname, SellerEmail = seller.Email, SellerCity = city.CityName, SalesNumber = s.SalesNumber, Cost = s.Cost }; return(list.ToList()); } }
private ShoppingList PrepareShoppingListViewModel(ShoppingListRequest list) { ShoppingList preppedList = new ShoppingList(); preppedList.StartDate = TimeTools.ConvertTimeStampToStringDate(list.startDate); preppedList.EndDate = TimeTools.ConvertTimeStampToStringDate(list.endDate); preppedList.TotalCost = (float)(list.cost * .01); preppedList.Items = new List <Item>(); foreach (Aisle aisle in list.aisles) { foreach (Item item in aisle.items) { if (CompareKitchenInventoryToIngredient(item) == false) { item.cost = (float)(item.cost * .01); preppedList.Items.Add(item); } else { preppedList.TotalCost -= (float)(item.cost * .01); continue; } } } return(preppedList); }
public ActionResult <ShoppingList> CreateShoppingList([FromBody] ShoppingListRequest request) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var shoppingList = new ShoppingList { Id = Guid.NewGuid(), Name = request.Name }; return(_service.AddList(shoppingList)); }
public List <ShoppingBasketResponse> ShoppingList(ShoppingListRequest shoppingListRequest) { return(shoppingBasketService.ShoppingList(shoppingListRequest)); }
public ActionResult <ShoppingList> UpdateShoppingList([FromRoute] Guid listId, [FromBody] ShoppingListRequest request) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var shoppingList = new ShoppingList { Id = listId, Name = request.Name }; var res = _service.UpdateList(shoppingList); if (res == null) { return(NotFound()); } return(res); }