예제 #1
0
 public void Delete(TEntity entityToDelete)
 {
     if (context.Entry(entityToDelete).State == EntityState.Detached)
     {
         dbSet.Attach(entityToDelete);
     }
     dbSet.Remove(entityToDelete);
 }
예제 #2
0
        public async Task <IActionResult> PutRestaurant(int id, Restaurant restaurant)
        {
            if (id != restaurant.Restaurant1)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
예제 #3
0
        public async Task <IActionResult> PutFood(int id, Food food)
        {
            if (id != food.FoodId)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
예제 #4
0
파일: OrderRepo.cs 프로젝트: Yoadad/Food
 public void EditOrder(Order order)
 {
     using (var db = new FoodContext())
     {
         db.Orders.Attach(order);
         db.Entry(order).State = System.Data.Entity.EntityState.Modified;
         db.SaveChanges();
     }
 }
예제 #5
0
 public void EditMenuDetail(MenuDetail menuDetail)
 {
     using (var db = new FoodContext())
     {
         db.MenuDetails.Attach(menuDetail);
         db.Entry(menuDetail).State = System.Data.Entity.EntityState.Modified;
         db.SaveChanges();
     }
 }
예제 #6
0
 public ActionResult Edit([Bind(Include = "Id,Name,Type")] Food.Models.Food food)
 {
     if (ModelState.IsValid)
     {
         db.Entry(food).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(food));
 }
예제 #7
0
 public ActionResult Edit([Bind(Include = "Id,Name")] Company company)
 {
     if (ModelState.IsValid)
     {
         db.Entry(company).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(company));
 }
예제 #8
0
 public ActionResult Edit([Bind(Include = "Id,SupplierName,Address,Description,Email,PhoneNumber")] Supplier supplier)
 {
     if (ModelState.IsValid)
     {
         db.Entry(supplier).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(supplier));
 }
예제 #9
0
        public async Task <ActionResult> Edit([Bind(Include = "Id,FoodName")] FoodType foodType)
        {
            if (ModelState.IsValid)
            {
                db.Entry(foodType).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(foodType));
        }
예제 #10
0
 public ActionResult Edit([Bind(Include = "Id,Date,Name,StatusId")] Order order)
 {
     if (ModelState.IsValid)
     {
         db.Entry(order).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.StatusId = new SelectList(db.OrderStatus, "Id", "Name", order.StatusId);
     return(View(order));
 }
예제 #11
0
 public ActionResult Edit([Bind(Include = "Id,Name,Area,CompanyId")] Location location)
 {
     if (ModelState.IsValid)
     {
         db.Entry(location).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.CompanyId = new SelectList(db.Companies, "Id", "Name", location.CompanyId);
     return(View(location));
 }
예제 #12
0
        public async Task <ActionResult> Edit([Bind(Include = "Id,Name,FoodTemperature,OvenTemperature,Instruction,FoodTypeId")] Recipe recipe)
        {
            if (ModelState.IsValid)
            {
                db.Entry(recipe).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            ViewBag.FoodTypeId = new SelectList(db.FoodTypes, "Id", "FoodName", recipe.FoodTypeId);
            return(View(recipe));
        }
예제 #13
0
 public ActionResult Edit([Bind(Include = "Id,MenuId,FoodId")] MenuDetail menuDetail)
 {
     if (ModelState.IsValid)
     {
         db.Entry(menuDetail).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.FoodId = new SelectList(db.Foods, "Id", "Name", menuDetail.FoodId);
     ViewBag.MenuId = new SelectList(db.Menus, "Id", "Name", menuDetail.MenuId);
     return(View(menuDetail));
 }
 public ActionResult Edit([Bind(Include = "Id,ProductName,Description,Image,UnitsPrice,Inventory,HadSold,DisContinued,CategoryId,SupplierId")] Product product)
 {
     if (ModelState.IsValid)
     {
         db.Entry(product).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.CategoryId = new SelectList(db.Categories, "Id", "CategoryName", product.CategoryId);
     ViewBag.SupplierId = new SelectList(db.Suppliers, "Id", "SupplierName", product.SupplierId);
     return(View(product));
 }
예제 #15
0
        public async Task <IActionResult> PutFoodItem(int Id, [FromBody] FoodItem item)
        {
            if (Id != item.Id)
            {
                return(BadRequest());
            }
            if (!_context.FoodItems.Contains(item))
            {
                return(BadRequest());
            }
            _context.Entry(item).State = EntityState.Modified;
            await _context.SaveChangesAsync();

            return(NoContent());
        }
예제 #16
0
        public async Task <IActionResult> PutEntry([FromRoute] int id, [FromBody] EntryDTO dto)
        {
            Console.WriteLine("I shouldn't be here!");

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != dto.EntryId)
            {
                return(BadRequest());
            }

            var entry = EntryMapper.Map(dto, new Entry());

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

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

            return(NoContent());
        }
예제 #17
0
 public void Update(Dish t)
 {
     context.Entry <Dish>(t).State = System.Data.Entity.EntityState.Modified;
     context.SaveChanges();
 }
 public ActionResult Edit(Restaurant restaurant)
 {
     _db.Entry(item).State = EntityState.Modified;
     _db.SaveChanges();
     return(RedirectToAction("Index"));
 }
예제 #19
0
 public void UpdateRecipe(Food food)
 {
     context.Entry(food).State = EntityState.Modified;
 }