public ActionResult CreateCurrentUserShoppingList([FromBody] ShoppingListCreateDto dto) { if (!auth.GetUserFromClaims(User.Claims, out var user)) { return(Unauthorized()); } var list = new ShoppingList(dto.Name) { Owner = user }; foreach (var entry in dto.Entries) { var product = repository.Products.GetAll().FirstOrDefault(p => p.Id == entry.ItemId); if (product is null) { return(BadRequest()); } list.AddEntry(new ShoppingListEntry(entry.Quantity, product)); } repository.ShoppingLists.Add(list); repository.SaveChanges(); return(CreatedAtRoute("GetCurrentUserShoppingListById", new { list.Id })); }
MatchWaypoints(ShoppingListCreateDto createDto) =>