public bool TrainerAddFoodItem(string userId, FoodItemDTO foodItem) { var trainer = (from x in db.trainer where x.ID == userId select x).FirstOrDefault(); try { var f = new foodItem { name = foodItem.name, category = foodItem.category, kcal = foodItem.kcal, fat = foodItem.fat, saturatedFat = foodItem.saturatedFat, unsaturatedFat = foodItem.unsaturatedFat, colestrol = foodItem.colestrol, carbohydrate = foodItem.carbohydrate, addedSugar = foodItem.addedSugar, fiber = foodItem.fiber, water = foodItem.water, protein = foodItem.protein, suppliment = foodItem.suppliment, trainer_TRID = trainer.TRID }; db.foodItem.Add(f); db.SaveChanges(); return(true); } catch (Exception) { return(false); } }
public bool UpdateFoodItem(FoodItemDTO fooditem) { try { var f = (from x in db.foodItem where x.FIID == fooditem.FIID select x ).SingleOrDefault(); f.FIID = fooditem.FIID; f.name = fooditem.name; f.kcal = fooditem.kcal; f.fat = fooditem.fat; f.saturatedFat = fooditem.saturatedFat; f.unsaturatedFat = fooditem.unsaturatedFat; f.colestrol = fooditem.colestrol; f.carbohydrate = fooditem.carbohydrate; f.addedSugar = fooditem.addedSugar; f.fiber = fooditem.fiber; f.water = fooditem.water; f.protein = fooditem.protein; f.suppliment = fooditem.suppliment; f.trainer_TRID = fooditem.trainer_TRID; db.SaveChanges(); return(true); } catch (Exception) { return(false); } }
public bool AddFoodItem(FoodItemDTO x) { try { var f = new foodItem { FIID = x.FIID, name = x.name, kcal = x.kcal, fat = x.fat, saturatedFat = x.saturatedFat, unsaturatedFat = x.unsaturatedFat, colestrol = x.colestrol, carbohydrate = x.carbohydrate, addedSugar = x.addedSugar, fiber = x.fiber, water = x.water, protein = x.protein, suppliment = x.suppliment, trainer_TRID = x.trainer_TRID }; db.foodItem.Add(f); db.SaveChanges(); return(true); } catch (Exception) { return(false); } }
public Schedule getScheduleForTrainee(string UserID) { Schedule schedule = new Schedule(); if (UserID != null) { List <Day> days = new List <Day>(); int s = getProgram(UserID); for (int d = 0; d < 7; d++) { List <FoodProgramPortionDTO> li = getProgramPortion(s, d); Day day = new Day(); day.weekday = d; List <Meal> meals = new List <Meal>(); for (int i = 0; i < li.Count; i++) { List <FoodPortionDTO> portions = getPortion(li[i].foodPortion_FPID); for (int j = 0; j < portions.Count; j++) { Meal meal = new Meal(); FoodItemDTO item = getFoodItem(portions[j].foodItem_FIID); meal.food = item; meal.time = li[j].timeOfDay.ToString(); meals.Add(meal); } day.meal = meals; } days.Add(day); } schedule.day = days; return(schedule); } return(schedule); }
public Meal(string time, FoodItemDTO food) { this.food = food; }
public bool UpdateFoodItem(FoodItemDTO fooditem) { return(fiq.UpdateFoodItem(fooditem)); }
public bool TrainerAddExercise(FoodItemDTO foodItem) { var userId = User.Identity.GetUserId(); return(fiq.TrainerAddFoodItem(userId, foodItem)); }
public bool AddFoodItem(FoodItemDTO fooditem) { return(fiq.AddFoodItem(fooditem)); }