Esempio n. 1
0
        public async Task <ActionResult> Edit([Bind(Include = "Id,Name,Subscription")] Diet diet)
        {
            if (ModelState.IsValid)
            {
                var ChoosenArr = Request.Cookies[namecookies]?.Value?.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);

                int[] arr = (ChoosenArr != null)?Array.ConvertAll(ChoosenArr, s => int.Parse(s)): new int[0];

                db.Entry(diet).State = EntityState.Modified;
                diet.UpdateDiet(arr);
                // await db.SaveChangesAsync();
                return(RedirectToAction("Index"));
            }
            return(View(diet));
        }