Esempio n. 1
0
        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));
        }
Esempio n. 2
0
 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);
 }
Esempio n. 3
0
        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());
        }
Esempio n. 4
0
        public async Task <object> PutFoodItems([FromBody] FoodItemModel mdl)
        {
            var endpoint = $"{LunchAppUrl}UpdateFoodItems/{mdl.PkId}/{mdl.CompanyId}";

            return(await _hcmAdminClient.SendDataToAPI(endpoint, "PUT", false, mdl));
        }
Esempio n. 5
0
        public async Task <string> GetAllCode([FromBody] FoodItemModel mdl)
        {
            var url = $"{LunchAppUrl}GetAllCodes/{mdl.Type}";

            return(await _hcmAdminClient.SendDataToAPI(url, "GET", false));
        }
Esempio n. 6
0
 public FoodItemModel Update(int id, FoodItemModel FoodItemModel)
 {
     throw new NotImplementedException();
 }
Esempio n. 7
0
 public FoodItemModel Create(FoodItemModel FoodItemModel)
 {
     _dbReference.FoodItemModel.Add(FoodItemModel);
     _dbReference.SaveChanges();
     return(FoodItemModel);
 }
Esempio n. 8
0
        private double GetFoodCalorieAmount(FoodItemModel foodItem)
        {
            var foodCalorie = (foodItem.Fat * 9) + (foodItem.Protine * 4) + (foodItem.Carbohydrate * 4);

            return(foodCalorie);
        }
Esempio n. 9
0
 public override void OnEnter()
 {
     _food  = GetFoodItem();
     _timer = 0.0f;
 }
Esempio n. 10
0
        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;
                }
            }
        }
Esempio n. 11
0
 //Update foodItems
 public async Task UpdateFoodItemModel(FoodItemModel foodItemModel)
 {
     await foodItemModelTable.UpdateAsync(foodItemModel);
 }
Esempio n. 12
0
 //delete foodItems
 public async Task DeleteFoodItemModel(FoodItemModel foodItemModel)
 {
     await foodItemModelTable.DeleteAsync(foodItemModel);;
 }
Esempio n. 13
0
 //Add fooditems
 public async Task AddFoodItemModel(FoodItemModel foodItemModel)
 {
     await this.foodItemModelTable.InsertAsync(foodItemModel);
 }
Esempio n. 14
0
 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)));
 }
Esempio n. 17
0
 public override void OnExit()
 {
     _food = null;
 }