public IResponse UpdateGroceryList(GroceryListViewModel groceryList) { // Convertion for groceryList view model object to a POCO groceryList object GroceryList groceryListUpdated = new GroceryList { GroceryListID = groceryList.GroceryListId, Products = groceryList.Products.Select(x => new ProductGroceryList { ProductID = x.ProductId, Tagged = x.Tagged, }).ToList() }; try { this.GroceryRepository.UpdateGroceryList(groceryListUpdated); this.GroceryRepository.Save(); return(new Response("0", "Success")); } catch (Exception ex) { //Logging exception and return an error response } return(new Response("1", "Error updating grocery list.")); }
public GroceryListController(IIngredientData ingredientData) { _ingredientData = ingredientData; GroceryList = new GroceryListViewModel { IngredientList = new List <Ingredient>() }; }
public GeneratedGroceryList(IList <ViewModel.GroceryListItemEditVM> list, DateTime startDate, DateTime finishDate) { InitializeComponent(); GroceryListViewModel viewModel = new GroceryListViewModel(); viewModel.Title = string.Format("Do dia {0} até o dia {1}", startDate.ToString("dd/MM/yyyy"), finishDate.ToString("dd/MM/yyyy")); viewModel.GroupedItems = InitializeListView(list); this.BindingContext = viewModel; }
public IHttpActionResult GroceryList([FromBody] GroceryListViewModel groceryListViewModel) { IResponse response = this.GroceryService.UpdateGroceryList(groceryListViewModel); return(Ok(response)); }
public GroceryListViewModelTests() { _repository = new MockRepository(); _bluetoothServices = new MockBluetoothServices(); _viewModel = new GroceryListViewModel(_repository, _bluetoothServices); }
public GroceryListPage() { viewModel = new GroceryListViewModel(); InitializeComponent(); BindingContext = viewModel; }