public ActionResult Index() { var contentService = Services.ContentService; var contentTypeService = Services.ContentTypeService; var contentType = contentTypeService.GetContentType("Menu"); var foodProviders = contentService.GetContentOfContentType(contentType.Id); var model = new FoodItemModel { FoodProviders = new List <SelectListItem>() }; foreach (var provider in foodProviders) { model.FoodProviders.Add(new SelectListItem { Value = provider.Id.ToString(CultureInfo.InvariantCulture), Text = provider.Name }); } var memberId = Members.GetCurrentMemberId(); var memberService = Services.MemberService; var member = memberService.GetById(memberId); if (Members.IsLoggedIn() && memberService.FindMembersInRole("Admin", member.Username).Any()) { model.MemberIsAdmin = true; } return(PartialView("~/Views/Partials/AdminFoodPartial.cshtml", model)); }
public override bool Update() { if (_timer > _eatTime) { _food.UseBy(Owner.Model); Owner.Model.Inventory.Remove(_food); _food = null; } else { _timer += Time.deltaTime; } return(_food == null); }
public ActionResult AddFoodItem(FoodItemModel model) { if (!ModelState.IsValid) { return(CurrentUmbracoPage()); } var contentService = Services.ContentService; var content = contentService.CreateContent(model.Title, model.FoodProviderId, "FoodItem"); content.SetValue("name", model.Name); contentService.SaveAndPublishWithStatus(content); return(RedirectToCurrentUmbracoPage()); }
public async Task <object> PutFoodItems([FromBody] FoodItemModel mdl) { var endpoint = $"{LunchAppUrl}UpdateFoodItems/{mdl.PkId}/{mdl.CompanyId}"; return(await _hcmAdminClient.SendDataToAPI(endpoint, "PUT", false, mdl)); }
public async Task <string> GetAllCode([FromBody] FoodItemModel mdl) { var url = $"{LunchAppUrl}GetAllCodes/{mdl.Type}"; return(await _hcmAdminClient.SendDataToAPI(url, "GET", false)); }
public FoodItemModel Update(int id, FoodItemModel FoodItemModel) { throw new NotImplementedException(); }
public FoodItemModel Create(FoodItemModel FoodItemModel) { _dbReference.FoodItemModel.Add(FoodItemModel); _dbReference.SaveChanges(); return(FoodItemModel); }
private double GetFoodCalorieAmount(FoodItemModel foodItem) { var foodCalorie = (foodItem.Fat * 9) + (foodItem.Protine * 4) + (foodItem.Carbohydrate * 4); return(foodCalorie); }
public override void OnEnter() { _food = GetFoodItem(); _timer = 0.0f; }
public async void insert_Clicked(object sender, EventArgs e) { //Progress bar ProgressIndicator.IsRunning = true; //Check to ensure a correct mood was entered and alert the staff member if not var i = moodInput.Text; if (i != "Happy" && i != "Angry" && i != "Contempt" && i != "Disgusted" && i != "Scared" && i != "Neutral" && i != "Sad" && i != "Surprised") { await DisplayAlert("Alert", "Invalid Mood! \n Please enter \n Happy, Angry, Contempt, \n Disgusted, Scared, Neutral,\n Sad or Surprised!", "OK"); //Progress bar ProgressIndicator.IsRunning = false; } else { //Check to see if feilds are empty if (nameInput.Text == null || priceInput.Text == null || Double.Parse(priceInput.Text) <= 2) { await DisplayAlert("Alert", "Please ensure all fields are filled out and valid!" + Environment.NewLine + "*Price must be greater than $2.*", "OK"); //Progress bar ProgressIndicator.IsRunning = false; } else { //Get userinput var nameText = nameInput.Text; var priceText = Double.Parse(priceInput.Text); //Create discounted price var emotionPriceText = priceText - 2; //Create heavily discounted price of Fabrikam Special for challenge if (nameInput.Text == "Fabrikam Special") { emotionPriceText = 5; } var moodText = moodInput.Text; FoodItemModel FoodItem = new FoodItemModel() { Name = nameText, Price = priceText, EmotionPrice = emotionPriceText, Mood = moodText }; //Insert item into database await AzureManager.AzureManagerInstance.AddFoodItemModel(FoodItem); await DisplayAlert("Alert", "Successfully Inserted new food item!", "OK"); //Progress bar ProgressIndicator.IsRunning = false; //Refresh the page App.RootPage.Detail = new NavigationPage(new FoodInputPage()); App.MenuIsPresented = false; } } }
//Update foodItems public async Task UpdateFoodItemModel(FoodItemModel foodItemModel) { await foodItemModelTable.UpdateAsync(foodItemModel); }
//delete foodItems public async Task DeleteFoodItemModel(FoodItemModel foodItemModel) { await foodItemModelTable.DeleteAsync(foodItemModel);; }
//Add fooditems public async Task AddFoodItemModel(FoodItemModel foodItemModel) { await this.foodItemModelTable.InsertAsync(foodItemModel); }
public void Init(FoodSourceHolder holder, FoodRepository repo) { _holder = holder; Model = repo.Create(); }
public IActionResult Create(FoodItemModel model) { return(Ok(_db.Create(model))); }
public IActionResult Update(int id, FoodItemModel model) { return(Ok(_db.Update(id, model))); }
public override void OnExit() { _food = null; }