public async void AddRcpToMenu() { RcpToMenu = new AddEditGetMenu() { MenuId = App.CurrentMenu.MenuId, RecipeId = Convert.ToInt32(App.RecipeViewModel.CurrentRcp.RecipeID), MenuServings = App.RecipeViewModel.CurrentRcp.RecipeServings, UserId = Data.CABEServices.UserDetails.ID, MenuName = App.CurrentMenu.MenuName }; await App.cabeMgr.AddEditGetMenuAsync(RcpToMenu); }
private async void OnAddToMenuClicked(object sender, EventArgs e) { RcpToMenu = new AddEditGetMenu() { RecipeId = Convert.ToInt32(App.RecipeViewModel.CurrentRcp.RecipeID), MenuServings = App.RecipeViewModel.CurrentRcp.RecipeServings, UserId = Data.CABEServices.UserDetails.ID, }; if (App.CurrentMenu == null) { var tempMenuId = 0; var tempMenuName = ""; // Establish CurrentMenu var menuList = await App.cabeMgr.GetSavedMenusAsync(CurrentUserID); if (menuList.Count > 0) { foreach (Menu menu in menuList) { if (menu.CurrentMenu == true) { tempMenuId = menu.Id; tempMenuName = menu.MenuName; } } } RcpToMenu.MenuId = tempMenuId; RcpToMenu.MenuName = tempMenuName; if (tempMenuId != 0) { var tempCurrentMenu = new MenuRecipe(); tempCurrentMenu.MenuId = tempMenuId; tempCurrentMenu.MenuName = tempMenuName; App.CurrentMenu = tempCurrentMenu; } await App.cabeMgr.AddEditGetMenuAsync(RcpToMenu); } else { RcpToMenu.MenuName = App.CurrentMenu.MenuName; RcpToMenu.MenuId = App.CurrentMenu.MenuId; await App.cabeMgr.AddEditGetMenuAsync(RcpToMenu); } await Navigation.PushAsync(new Pages.CurrentMenuPage()); }
public async Task <AddEditGetMenu> AddEditGetMenuAsync(AddEditGetMenu rcpToMenu, bool isNew = true) { PushRcpToMenu = new AddEditGetMenu(); var uri = new Uri(string.Format(Constants.AddEditMenuUrl)); try { var json = JsonConvert.SerializeObject(rcpToMenu); var content = new StringContent(json, Encoding.UTF8, "application/json"); HttpResponseMessage response = null; if (isNew) { response = await client.PostAsync(uri, content); if (response.IsSuccessStatusCode) { var addRcp = await response.Content.ReadAsStringAsync(); PushRcpToMenu = JsonConvert.DeserializeObject <AddEditGetMenu>(addRcp); } } else { response = await client.PutAsync(uri, content); } if (response.IsSuccessStatusCode) { Debug.WriteLine(@" recipe successfully saved to menu."); } } catch (Exception ex) { Debug.WriteLine(@" ERROR {0}", ex.Message); } return(PushRcpToMenu); }
public Task <AddEditGetMenu> AddEditGetMenuAsync(AddEditGetMenu rcpToMenu, bool isNew = true) { return(restService.AddEditGetMenuAsync(rcpToMenu, isNew)); }