Ejemplo n.º 1
0
        // GET: Supply/Details/5
        public ActionResult Details(int id)
        {
            var viewModel = new SupplyListAndSupplyViewModel
            {
                Supply = SupplyHelper.GetAllSupplies().Where(x => x.Id.Equals(id)).FirstOrDefault()
            };

            return(View(viewModel));
        }
Ejemplo n.º 2
0
        // GET: Supply
        public ActionResult Index()
        {
            var viewModel = new SupplyListAndSupplyViewModel
            {
                Supplies = SupplyHelper.GetAllSupplies()
            };

            return(View("Supply", viewModel));
        }
Ejemplo n.º 3
0
        // GET: Supply/Edit/5
        public ActionResult Edit(int id)
        {
            var viewModel = new SupplyListAndSupplyViewModel
            {
                Supply      = SupplyHelper.GetAllSupplies().Where(x => x.Id == id).FirstOrDefault(),
                Ingredients = MealHelper.GetAllIngredients().Select(i => new SelectListItem {
                    Value = i.Id.ToString(), Text = i.Name
                }).ToList()
            };

            return(View(viewModel));
        }
Ejemplo n.º 4
0
 public ActionResult Delete(string id)
 {
     try
     {
         SupplyHelper.DeleteSupply(id);
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(Content("Neche moci delitate ovo"));
     }
 }
Ejemplo n.º 5
0
        public ActionResult Edit(int editId, SupplyListAndSupplyViewModel PostSupply)
        {
            if (!ModelState.IsValid)
            {
                return(RedirectToAction("Edit"));
            }

            var ingredientNum      = int.Parse(PostSupply.PostIngredient);
            var selectedIngredient = MealHelper.GetAllIngredients().Where(x => x.Id == ingredientNum).FirstOrDefault();

            PostSupply.Supply.Ingredient = selectedIngredient;

            SupplyHelper.UpdateSupply(editId, PostSupply.Supply);

            return(RedirectToAction("Index"));
        }
Ejemplo n.º 6
0
        public ActionResult Create(SupplyListAndSupplyViewModel PostSupply)
        {
            if (!ModelState.IsValid)
            {
                return(RedirectToAction("Create"));
            }

            var ingredientNum      = int.Parse(PostSupply.PostIngredient);
            var selectedIngredient = MealHelper.GetAllIngredients().Where(x => x.Id == ingredientNum).FirstOrDefault();

            PostSupply.Supply.Ingredient = selectedIngredient;

            PostSupply.Supply.Id = SupplyHelper.GetSupplyNextId();

            SupplyHelper.AddSupply(PostSupply.Supply);

            return(RedirectToAction("Index"));
        }