/// <summary> /// Post example /// </summary> /// <param name="startDateDecorator"></param> public SynchronizationData Post(DateTimeDecorator startDateDecorator) { if (!ModelState.IsValid) { ModelState.AddModelError("", "Input data format is invalid."); return(null); } DateTime startDate = startDateDecorator.DateTime; var data = new SynchronizationData(); context = Request.GetOwinContext().Get <ApplicationDbContext>(); foodConsistencyTypeService = new FoodConsistencyTypeService(context); data.FoodConsistencyTypes = foodConsistencyTypeService.Get(startDate).ToList(); foodCategoryService = new FoodCategoryService(context); data.FoodCategories = foodCategoryService.Get(startDate).ToList(); dishCategoryService = new DishCategoryService(context); data.DishCategories = dishCategoryService.Get(startDate).ToList(); foodService = new FoodService(context); data.Food = foodService.Get(startDate).ToList(); dishService = new DishService(context); data.Dishes = dishService.Get(startDate).ToList(); portionService = new PortionFoodService(context); data.Portions = portionService.Get(startDate).ToList(); return(data); }
public ActionResult Index() { IEnumerable <DishCategoryViewModel> model = DishCategoryService.Get() .Select(dc => new DishCategoryViewModel { Id = dc.Id, DateModification = dc.DateModification, Image = dc.Image, IsDeleted = dc.IsDeleted, Name = dc.Name, }).ToList(); return(View(model)); }
public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Dish dish = DishService.Get(id.Value); //List<String> strings = new List<String>(); SelectList list = new SelectList(DishCategoryService.Get(), "Id", "Name"); list.First(i => { // strings.Add(i.Text); return(i.Value == dish.IdDishCategory.ToString()); }).Selected = true; ViewBag.IdDishCategory = list; ViewBag.DishToView = dish; return(View(dish.PortionFood)); }