Exemplo n.º 1
0
 public ActionResult Edit(UserProfile userprofile)
 {
     if (ModelState.IsValid)
     {
         db.Entry(userprofile).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("MyDetails"));
     }
     return(View(userprofile));
 }
Exemplo n.º 2
0
 public ActionResult Edit(Order order)
 {
     if (ModelState.IsValid)
     {
         db.Entry(order).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(order));
 }
        public ActionResult Edit(Dish dish, int[] usedIngredients)
        {
            Dish newDish = db.Dishes.Find(dish.Id);

            newDish.DishName = dish.DishName;
            newDish.Category = dish.Category;
            newDish.Price    = dish.Price;
            newDish.Weight   = dish.Weight;
            newDish.Note     = dish.Note;
            // newDish.Popularity = dish.Popularity;


            newDish.Ingredients.Clear();
            if (usedIngredients != null)
            {
                //получаем выбранные курсы
                foreach (var c in db.Ingredients.Where(co => usedIngredients.Contains(co.Id)))
                {
                    newDish.Ingredients.Add(c);
                }
            }

            db.Entry(newDish).State = EntityState.Modified;
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult Edit([Bind(Include = "Id,Email,Password,LName,FName,Sex,Visit")] User user)
 {
     if (ModelState.IsValid)
     {
         db.Entry(user).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(user));
 }
Exemplo n.º 5
0
 public ActionResult Edit([Bind(Include = "Id,IngredientName")] Ingredient ingredient)
 {
     if (ModelState.IsValid)
     {
         db.Entry(ingredient).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(ingredient));
 }
Exemplo n.º 6
0
 public ActionResult Edit(MenuItem menuitem)
 {
     if (ModelState.IsValid)
     {
         db.Entry(menuitem).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(menuitem));
 }
Exemplo n.º 7
0
 public ActionResult Edit(Statistics statistics)
 {
     if (ModelState.IsValid)
     {
         db.Entry(statistics).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(statistics));
 }
Exemplo n.º 8
0
 public ActionResult Edit([Bind(Include = "Id,DateOfMenu,AdminId")] Menu menu)
 {
     if (ModelState.IsValid)
     {
         db.Entry(menu).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.AdminId = new SelectList(db.Admins, "Id", "Login", menu.AdminId);
     return(View(menu));
 }
 public ActionResult Edit([Bind(Include = "Id,DateOfZakaz,UserId")] Zakaz zakaz)
 {
     if (ModelState.IsValid)
     {
         db.Entry(zakaz).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.UserId = new SelectList(db.Users, "Id", "Email", zakaz.UserId);
     return(View(zakaz));
 }
Exemplo n.º 10
0
        // PUT api/Default1/5
        public HttpResponseMessage PutOrder(int id, Order order)
        {
            if (ModelState.IsValid && id == order.OrderId)
            {
                db.Entry(order).State = EntityState.Modified;

                try
                {
                    db.SaveChanges();
                }
                catch (DbUpdateConcurrencyException)
                {
                    return(Request.CreateResponse(HttpStatusCode.NotFound));
                }

                return(Request.CreateResponse(HttpStatusCode.OK));
            }
            else
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest));
            }
        }
        void IRepository <TEntity> .Remove(int id)
        {
            var entry = Context.Entry(This.Get(id));

            entry.State = EntityState.Deleted;
        }
Exemplo n.º 12
0
 public void Update(T entity)
 {
     _context.Set <T>().Attach(entity);
     _context.Entry(entity).State = EntityState.Modified;
 }
 public async Task UpdateAsync(T entity)
 {
     _db.Entry(entity).State = EntityState.Modified;
     await _db.SaveChangesAsync();
 }