Exemplo n.º 1
0
        public async Task <IActionResult> PutItem(int id, Item item)
        {
            if (id != item.ItemId)
            {
                return(BadRequest());
            }

            _context.Entry(item).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ItemExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Exemplo n.º 2
0
        public async Task <IActionResult> PutCustomer(int id, Customer customer)
        {
            if (id != customer.CustomerId)
            {
                return(BadRequest());
            }

            _context.Entry(customer).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CustomerExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
 public ActionResult Edit(Restaurant restaurant)
 {
     if (ModelState.IsValid)
     {
         _context.Entry(restaurant).State = System.Data.Entity.EntityState.Modified;
         return(SaveAndRedirect());
     }
     return(View(restaurant));
 }
 public ActionResult Edit([Bind(Include = "RestaurantID,Name,Address,Rating")] Restaurant restaurant)
 {
     if (ModelState.IsValid)
     {
         db.Entry(restaurant).State = System.Data.Entity.EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(restaurant));
 }
 public ActionResult Edit(Restaurant restaurant)
 {
     if (ModelState.IsValid)
     { //another way to save changes
         _db.Entry(restaurant).State = System.Data.Entity.EntityState.Modified;
         _db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(restaurant));
 }
 public ActionResult Edit(Restaurant restaurant)
 {
     if (ModelState.IsValid)
     {
         _db.Entry(restaurant).State = EntityState.Modified;
         _db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(restaurant));
 }
Exemplo n.º 7
0
 public ActionResult Edit([Bind(Include = "ID,name,location,no_of_rooms,no_of_staff")] Restaurant restaurant)
 {
     if (ModelState.IsValid)
     {
         db.Entry(restaurant).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(restaurant));
 }
Exemplo n.º 8
0
 public ActionResult Edit([Bind(Include = "Restaurant,Name,Address,Rating")] Restaurant restaurant)
 {
     if (ModelState.IsValid)
     {
         //Entity: altering content
         db.Entry(restaurant).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(restaurant));
 }
Exemplo n.º 9
0
        public bool UpdateOrder(Order order)
        {
            bool isUpdated = false;

            objRestaurantContext.Entry(order).State = EntityState.Modified;
            try
            {
                objRestaurantContext.SaveChanges();
                isUpdated = true;
            }
            catch (DbUpdateConcurrencyException exDbupdate)
            {
                if (!OrderExists(order.OrderId))
                {
                    Console.WriteLine("Order not found");
                }
                else
                {
                    Console.WriteLine(exDbupdate);
                }
            }
            return(isUpdated);
        }
Exemplo n.º 10
0
 public void Update(T entity)
 {
     dbSet.Attach(entity);
     _dBConn.Entry(entity).State = EntityState.Modified;
     _dBConn.SaveChanges();
 }
Exemplo n.º 11
0
 public void Update(Ingredient ingredient)
 {
     db.Entry(ingredient).State = EntityState.Modified;
 }
 public bool Create(PdbRestaurant res)
 {
     _context.PdbRestaurants.Add(res);
     _context.Entry(res).State = System.Data.Entity.EntityState.Added;
     return(_context.SaveChanges() == 1);
 }
Exemplo n.º 13
0
 public bool Create(PdbFood fo)
 {
     _context.PdbFoods.Add(fo);
     _context.Entry(fo).State = System.Data.Entity.EntityState.Added;
     return(_context.SaveChanges() == 1);
 }
Exemplo n.º 14
0
 public void Update(Dish dish)
 {
     db.Entry(dish).State = EntityState.Modified;
 }
 public bool Create(PdbBookTable ban)
 {
     _context.PdbBookTables.Add(ban);
     _context.Entry(ban).State = System.Data.Entity.EntityState.Added;
     return(_context.SaveChanges() == 1);
 }