Пример #1
0
        public ActionResult ChangeRestrictions(ChangeRestrictionsViewModel updateRes)
        {
            string userCheck = m.GetCurrentUsername();
            int    idNum     = m.FetchUserId(userCheck);

            m.DeleteIngredsForUser(idNum);
            if (updateRes.selectedIngredientsId != null)
            {
                m.UpdateIngredsForUser(idNum, updateRes.selectedIngredientsId);
            }

            updateRes.allIngredients    = m.IngredGetAll();
            updateRes.chosenIngredients = m.IngredsForUserProfile(idNum);
            return(View(updateRes));
        }
Пример #2
0
        public ActionResult ChangeRestrictions()
        {
            string userCheck = m.GetCurrentUsername();
            int    idNum     = m.FetchUserId(userCheck);

            IEnumerable <IngredientBaseViewModel> restrictions = m.IngredsForUserProfile(idNum);

            String[] selectedRestrictions = m.IngredsForUser(idNum).ToArray();

            ChangeRestrictionsViewModel resChange = new ChangeRestrictionsViewModel();

            resChange.allIngredients        = m.IngredGetAll();
            resChange.chosenIngredients     = restrictions;
            resChange.selectedIngredientsId = selectedRestrictions;

            return(View(resChange));
        }