public CalculateModel CalculateDay(int dayId /*, int weight*/) { var day = _repository.GetDay(dayId); for (int i = 40; i <= 100; i += 5) { int weight = i; defaultDayOptions = new DayCalculation(day.Meals.Sum(x => x.Dishes.Count)) { Calories = day.Week.DietProgram.Calories * weight, Proteins = day.Week.DietProgram.Proteins * weight, Fats = day.Week.DietProgram.Fats * weight, Carbohydrates = day.Week.DietProgram.Carbohydrates * weight, BreakfastCoefficient = 40, LunchCoefficient = 40, DinnerCoefficient = 20 }; var dishList = GetDishParamList(day.Meals).OrderByDescending(x => x.GetInterval).ToList(); iterCount = 0; CalculateBestDay(dishList); WriteCalculation(day, dishList, i); bestDayOptions = null; } return(new CalculateModel()); }
public IActionResult EditDay(int weekId, DaysOfWeek dayName) { try { var model = _repository.GetDay(weekId, dayName); if (model == null) { model = _repository.AddDay(new Day { WeekId = weekId, DayName = dayName }); } else { _repository.DeleteCalculationsByDay(model); } return(View(model)); } catch (Exception ex) { return(View("Error", ex)); } }