示例#1
0
        public ActionResult LogAllergy()
        {
            AddAllergenViewModel model = new AddAllergenViewModel();

            model.allergens = new SelectList(db.Allergens.ToList(), "id", "KnownAllergies");
            return(View(model));
        }
示例#2
0
        public ActionResult LogAllergy(AddAllergenViewModel model)
        {
            var customer           = GetCustomer();
            AllergenJunction table = new AllergenJunction();

            table = db.AllergensJunction.Where(a => a.CustomerId == customer.id && a.AllergenId == model.id).FirstOrDefault();
            if (table == null)
            {
                table            = new AllergenJunction();
                table.AllergenId = model.id;
                table.CustomerId = customer.id;
                db.AllergensJunction.Add(table);
                db.SaveChanges();
            }

            AddAllergenViewModel newModel = new AddAllergenViewModel();

            newModel.allergens = new SelectList(db.Allergens.ToList(), "id", "KnownAllergies");
            return(View(newModel));
        }