public async Task Remove(int?Id) { var customer = await GetById(Id); _repository.Order.Remove(customer); await _repository.SaveChangesAsync(); }
public async Task <IActionResult> PutOrder(int id, Order order) { if (id != order.OrderId) { return(BadRequest()); } _context.Entry(order).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!OrderExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutPhieuNhapKho(int id, PhieuNhapKho phieuNhapKho) { if (id != phieuNhapKho.Id) { return(BadRequest()); } _context.Entry(phieuNhapKho).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PhieuNhapKhoExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutLocationRestaurant(int id, LocationRestaurant locationRestaurant) { if (id != locationRestaurant.Id) { return(BadRequest()); } _context.Entry(locationRestaurant).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!LocationRestaurantExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutKhachHang(int id, KhachHang khachHang) { if (id != khachHang.Id) { return(BadRequest()); } _context.Entry(khachHang).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!KhachHangExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutDish(int id, Dish dish) { if (id != dish.Id) { return(BadRequest()); } _context.Entry(dish).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DishExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <ActionResult <Order> > PostOrder(Order order) { if (order.OrderId == 0) { _context.Order.Add(order); } else { _context.Entry(order).State = EntityState.Modified; } // delete existing order details foreach (var orderDetail in order.OrderDetails) { if (order.DeletedOrderDetailsId != null && order.DeletedOrderDetailsId.Contains(orderDetail.OrderDetailId)) { _context.Entry(orderDetail).State = EntityState.Deleted; } else { if (orderDetail.OrderDetailId > 0) { _context.Entry(orderDetail).State = EntityState.Modified; } else { _context.Entry(orderDetail).State = EntityState.Added; } } } await _context.SaveChangesAsync(); return(CreatedAtAction("GetOrder", new { id = order.OrderId }, null)); }
public async Task <IActionResult> Create(int productId, [Bind("Id,Date,Price,Amount,ProviderId,ProductId,RestaurantId,Status,PlanReturn,FactReturn")] Order order) { order.ProductId = productId; var todayDate = DateTime.Now; if (order.Date > todayDate) { ModelState.AddModelError("Date", "Некорректна дата"); } if (order.PlanReturn < order.Date) { ModelState.AddModelError("PlanReturn", "Некорректна дата повернення"); } if (order.Amount <= 0) { ModelState.AddModelError("Amount", "Некорректна кількість"); } if (order.Price < 0) { ModelState.AddModelError("Price", "Некорректна вартість"); } if (ModelState.IsValid) { _context.Add(order); await _context.SaveChangesAsync(); return(RedirectToAction("Index", "Orders", new { Id = productId, name = _context.Products.Where(p => p.Id == productId).FirstOrDefault().Name })); //_context.Products.Where(p => p.Id == id).FirstOrDefault().Name }); } // ViewData["ProductId"] = new SelectList(_context.Products, "Id", "Id", order.ProductId); ViewData["ProviderId"] = new SelectList(_context.Providers, "Id", "Address", order.ProviderId); ViewData["RestaurantId"] = new SelectList(_context.Restaurants, "Id", "Address", order.RestaurantId); return(RedirectToAction("Index", "Orders", new { Id = productId, name = _context.Products.Where(p => p.Id == productId).FirstOrDefault().Name })); }
public async Task <IActionResult> PutRestaurants([FromRoute] int id, [FromBody] Restaurants restaurants) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != restaurants.Id) { return(BadRequest()); } _context.Entry(restaurants).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!RestaurantsExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutCity(long id, City city) { if (id != city.Id) { return(BadRequest()); } _context.Entry(city).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CityExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutThanhPhanMonAn(int id, ThanhPhanMonAn thanhPhanMonAn) { if (id != thanhPhanMonAn.Id) { return(BadRequest()); } _context.Entry(thanhPhanMonAn).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ThanhPhanMonAnExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutMenu(int id, Menu menu) { if (id != menu.MenuId) { return(BadRequest()); } _context.Entry(menu).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!MenuExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task Remove(int?Id) { var menuItem = await GetById(Id); _repository.MenuItem.Remove(menuItem); await _repository.SaveChangesAsync(); }
public async Task <IActionResult> PutEmployee(int id, Employee employee) { if (id != employee.Id) { return(BadRequest()); } _context.Entry(employee).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!EmployeeExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> Create([Bind("Id,Image,Name,Surname,Phone,Position,DateOfBirth,Salary,HomeAddress,RestaurantId")] Employee employee) { var todaysDate = DateTime.Today; if ((todaysDate.Year - employee.DateOfBirth.Year) < 14) { ModelState.AddModelError("DateOfBirth", "Некорректна дата"); } if (employee.Salary < 0) { ModelState.AddModelError("Salary", "Некорректна зарплата"); } if (string.IsNullOrEmpty(employee.Name)) { ModelState.AddModelError("Name", "Некорректне ім'я"); } if (string.IsNullOrEmpty(employee.Surname)) { ModelState.AddModelError("Surname", "Некорректне прізвище"); } if (ModelState.IsValid) { _context.Add(employee); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["RestaurantId"] = new SelectList(_context.Restaurants, "Id", "Name", employee.RestaurantId); return(View(employee)); }
public async Task <ActionResult> CreateRestaurantAsync([FromBody] Models.Restaurant restaurant) { restaurantContext.Restaurants.Add(restaurant); await restaurantContext.SaveChangesAsync(); return(CreatedAtAction(nameof(GetRestaurantAsync), new { id = restaurant.Id }, restaurant)); }
public async Task Add(User user) { await _dataContext.Users.AddAsync(user); await _dataContext.SaveChangesAsync(); await Task.CompletedTask; }
public async Task Add(Dish dish) { await _dataContext.Dishes.AddAsync(dish); await _dataContext.SaveChangesAsync(); await Task.CompletedTask; }
public async Task <IActionResult> Create([Bind("ID,Name,Address,City,State,Phone,OwnerName,RegistrationDate")] Restaurant restaurant) { if (ModelState.IsValid) { _context.Add(restaurant); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(restaurant)); }
public async Task <IActionResult> Create([Bind("Id_restaurante,Nombre,Descripcion,Direccion,H_apertura,H_cierre,Logo,Imagen_item")] tbl_Restaurantes tbl_Restaurantes) { if (ModelState.IsValid) { _context.Add(tbl_Restaurantes); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(tbl_Restaurantes)); }
public async Task <IActionResult> Create([Bind("ID,OwnerName,Adress")] Owners owners) { if (ModelState.IsValid) { _context.Add(owners); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(owners)); }
public async Task <IActionResult> Create([Bind("Id_votacion,Id_restaurante,Id_dato,Votacion")] tbl_Votaciones tbl_Votaciones) { if (ModelState.IsValid) { _context.Add(tbl_Votaciones); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(tbl_Votaciones)); }
public async Task <IActionResult> Create([Bind("PlateID,Name,Ingredients,Price,Serves")] Plate plate) { if (ModelState.IsValid) { _context.Add(plate); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(plate)); }
public async Task <IActionResult> Create([Bind("Id,Name,Address,Phone,Site,GeoLong,GeoLat")] Restaurant restaurant) { if (ModelState.IsValid) { _context.Add(restaurant); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(restaurant)); }
public async Task <IActionResult> Create([Bind("Id_rol,Rol,Descripcion")] tbl_Roles tbl_Roles) { if (ModelState.IsValid) { _context.Add(tbl_Roles); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(tbl_Roles)); }
public async Task <IActionResult> Create([Bind("Id_dato,Nombre,Apellido,Direccion,Eliminacion")] tbl_Datos tbl_Datos) { if (ModelState.IsValid) { _context.Add(tbl_Datos); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(tbl_Datos)); }
public async Task <IActionResult> Create([Bind("Id_usuario,Id_dato,Id_rol,Usuario,Clave,Estado")] tbl_Usuarios tbl_Usuarios) { if (ModelState.IsValid) { _context.Add(tbl_Usuarios); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(tbl_Usuarios)); }
public async Task <ActionResult> Create([Bind(Include = "ProductId,ProductType,Name,ThumbNail,FullImage,ShortDesc,FullDesc,Price")] Product product) { if (ModelState.IsValid) { db.Products.Add(product); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(product)); }
public async Task <IActionResult> Create([Bind("ProductName,Description,ImagePath,UnitPrice,CategoryID")] Product product) { if (ModelState.IsValid) { _context.Add(product); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["CategoryID"] = new SelectList(_context.Categories, "CategoryID", "CategoryName", product.CategoryID); return(View(product)); }
public async Task <IActionResult> Create([Bind("Id,Image,Name,Type,Weight,Price,Remarks,RestaurantId")] Dish dish) { // dish.RestaurantId =restaurantId; if (ModelState.IsValid) { _context.Add(dish); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index)));//"Index", "Dishes", new { id = restaurantId, name = _context.Restaurants.Where(e => e.Id == restaurantId).FirstOrDefault().Name }) ; } ViewData["RestaurantId"] = new SelectList(_context.Restaurants, "Id", "Name"); return(View(dish));//RedirectToAction("Index", "Dishes", new { id = restaurantId, name = _context.Restaurants.Where(e => e.Id == restaurantId).FirstOrDefault().Name }); }