コード例 #1
0
        public ActionResult Edit([Bind(Include = "id_ingredient,name_ingredient")] ingredient ingredient)
        {
            if (ModelState.IsValid)
            {
                db.Entry(ingredient).State = EntityState.Modified;

                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            return(View(ingredient));
        }
コード例 #2
0
ファイル: HomeController.cs プロジェクト: angelabarros/MyCOOK
        public ActionResult testeEdit(preference p, mycook.Models.preference usermodel)
        {
            mycookEntities me = new mycookEntities();



            var prefDetails = me.preferences.Where(x => x.id_preference == usermodel.id_preference).FirstOrDefault();

            if (prefDetails != null)
            {
                preference editado = prefDetails;
                editado.description = usermodel.description;
                editado.type        = usermodel.type;
                editado.status      = "ON";
                usermodel.status    = "ON";

                if (usermodel.type.ToLower().Equals("free") || usermodel.type.ToLower().Equals("paid"))
                {
                    me.SaveChanges();
                    db.Entry(p).State = EntityState.Modified;
                    db.SaveChanges();
                    return(RedirectToAction("Preferences"));
                }
                else
                {
                    ViewData["TYPE"] = "Data was saved successfully.";
                    return(View("Edit", usermodel));
                }
            }
            else
            {
            }
            return(RedirectToAction("Preferences"));
        }
コード例 #3
0
        public IHttpActionResult Putingredients_recipe(decimal id, ingredients_recipe ingredients_recipe)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != ingredients_recipe.id_recipe)
            {
                return(BadRequest());
            }

            db.Entry(ingredients_recipe).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ingredients_recipeExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
コード例 #4
0
        public IHttpActionResult Putstep(decimal id, step step)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != step.id_step)
            {
                return(BadRequest());
            }

            db.Entry(step).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!stepExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
コード例 #5
0
ファイル: userController.cs プロジェクト: angelabarros/MyCOOK
        public ActionResult testeEdit([Bind(Include = "id_user,username,password,role, subscription")] user user, mycook.Models.user usermodel)
        {
            mycookEntities me = new mycookEntities();



            var userDetails = me.users.Where(x => x.id_user == usermodel.id_user).FirstOrDefault();

            if (userDetails != null)
            {
                user editado = userDetails;
                editado.username     = usermodel.username;
                editado.password     = usermodel.password;
                editado.subscription = usermodel.subscription;
                editado.role         = usermodel.role;
                editado.status       = "ON";
                usermodel.status     = "ON";
                user.status          = "ON";
                me.SaveChanges();
                db.Entry(user).State = EntityState.Modified;
                db.SaveChanges();
                // return RedirectToAction("Index");
                TempData["msg"] = "Record Saved Successfully.";
                // ViewBag.DataExists = true;
                // ViewBag.Javascript = "<script language='javascript' type='text/javascript'>alert('Data Already Exists');</script>";

                return(RedirectToAction("admins"));
            }
            else
            {
                usermodel.LoginErrorMessage = "Error";
            }
            return(RedirectToAction("admins"));
        }
コード例 #6
0
        public ActionResult testeEdit(preference p, mycook.Models.preference usermodel)
        {
            mycookEntities me = new mycookEntities();



            var prefDetails = me.preferences.Where(x => x.id_preference == usermodel.id_preference).FirstOrDefault();

            if (prefDetails != null)
            {
                preference editado = prefDetails;
                editado.description = usermodel.description;
                editado.type        = usermodel.type;


                ;
                me.SaveChanges();
                db.Entry(p).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Preferences"));
            }
            else
            {
            }
            return(RedirectToAction("Preferences"));
        }
コード例 #7
0
 public ActionResult Edit([Bind(Include = "id_user,username,role")] user user)
 {
     if (ModelState.IsValid)
     {
         db.Entry(user).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(user));
 }
コード例 #8
0
 public ActionResult Edit([Bind(Include = "id_step,id_recipe,description,number_order")] step step)
 {
     if (ModelState.IsValid)
     {
         db.Entry(step).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.id_recipe = new SelectList(db.recipes, "id_recipe", "name_recipe", step.id_recipe);
     return(View(step));
 }