public async Task <IActionResult> Edit(int id, [Bind("CustomerId,Name,Surname,Phone,CreatedDateTime,LastModifiedDateTime")] Customer customer) { if (id != customer.CustomerId) { return(NotFound()); } if (ModelState.IsValid) { try { if (customer.CreatedDateTime.Year < 2000) { customer.CreatedDateTime = DateTime.Now; } customer.LastModifiedDateTime = DateTime.Now; _context.Update(customer); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CustomerExists(customer.CustomerId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(customer)); }
public async Task <IActionResult> Edit(int id, [Bind("InvoiceId,OrderId,DeliveryPrice,TotalAmt,Discount,DateTime,CreatedDateTime,LastModifiedDateTime")] Invoice invoice) { if (id != invoice.InvoiceId) { return(NotFound()); } if (ModelState.IsValid) { try { if (invoice.CreatedDateTime.Year < 2000) { invoice.CreatedDateTime = DateTime.Now; } invoice.LastModifiedDateTime = DateTime.Now; _context.Update(invoice); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!InvoiceExists(invoice.InvoiceId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["OrderId"] = new SelectList(_context.Order, "OrderId", "OrderId", invoice.OrderId); return(View(invoice)); }
public async Task <IActionResult> Edit(int id, [Bind("SalaryPaymentId,CourierId,StartPeriodDate,EndPeriodDate,DeliveriesCount,PaymentForDeliveries,Premium,FineAmt,PaymentAmt,CreatedDateTime,LastModifiedDateTime")] SalaryPayment salaryPayment) { if (id != salaryPayment.SalaryPaymentId) { return(NotFound()); } if (ModelState.IsValid) { try { if (salaryPayment.CreatedDateTime.Year < 2000) { salaryPayment.CreatedDateTime = DateTime.Now; } salaryPayment.LastModifiedDateTime = DateTime.Now; _context.Update(salaryPayment); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SalaryPaymentExists(salaryPayment.SalaryPaymentId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["CourierId"] = new SelectList(_context.Courier, "CourierId", "Name", salaryPayment.CourierId); return(View(salaryPayment)); }
public async Task <IActionResult> Edit(int id, [Bind("CourierId,Name,Surname,Phone,CourierTypeId,CreatedDateTime,LastModifiedDateTime")] Courier courier) { if (id != courier.CourierId) { return(NotFound()); } if (ModelState.IsValid) { try { if (courier.CreatedDateTime.Year < 2000) { courier.CreatedDateTime = DateTime.Now; } courier.LastModifiedDateTime = DateTime.Now; _context.Update(courier); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CourierExists(courier.CourierId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["CourierTypeId"] = new SelectList(_context.CourierType, "CourierTypeId", "Type", courier.CourierTypeId); return(View(courier)); }
public async Task <IActionResult> Create([Bind("OrderLineId,OrderId,RestaurantDishRelationId,Quantity,CreatedDateTime,LastModifiedDateTime")] OrderLine orderLine) { if (ModelState.IsValid) { orderLine.CreatedDateTime = DateTime.Now; orderLine.LastModifiedDateTime = DateTime.Now; var order = _context.Order.Find(orderLine.OrderId); order.TotalAmt = order.OrderLine.Sum(o => o.Quantity * o.RestaurantDishRelation.Price); _context.Update(order); _context.Add(orderLine); await _context.SaveChangesAsync(); return(RedirectToRoute(new { controller = "Orders", action = "Details", id = orderLine.OrderId })); //return RedirectToAction(nameof(Index)); } ViewData["OrderId"] = new SelectList(_context.Order, "OrderId", "OrderId", orderLine.OrderId); ViewData["RestaurantDishRelationId"] = new SelectList(_context.RestaurantDishRelation, "RestaurantDishRelationId", "RestaurantDishRelationId", orderLine.RestaurantDishRelationId); return(RedirectToRoute(new { controller = "Details", action = "Order", id = orderLine.OrderId })); }
// GET: Orders/Details/5 public async Task <IActionResult> Details(int?id) { if (id == null) { return(NotFound()); } var order = await _context.Order .Include(o => o.Customer) .Include(o => o.Invoice) .Include(o => o.OrderLine) .ThenInclude(o => o.RestaurantDishRelation) .ThenInclude(o => o.Dish) .ThenInclude(o => o.UnitOfMeasure) .Include(o => o.Delivery) .ThenInclude(o => o.Location) .ThenInclude(o => o.Street) .ThenInclude(o => o.District) .ThenInclude(o => o.City) .Include(o => o.Delivery) .ThenInclude(o => o.Courier) .FirstOrDefaultAsync(m => m.OrderId == id); if (order == null) { return(NotFound()); } order.TotalAmt = order.OrderLine.Sum(o => o.Quantity * o.RestaurantDishRelation.Price); _context.Update(order); await _context.SaveChangesAsync(); return(View(order)); }
public async Task <IActionResult> Edit(int id, [Bind("RestaurantDishRelationId,RestaurantId,DishId,Price,CreatedDateTime,LastModifiedDateTime")] RestaurantDishRelation restaurantDishRelation) { if (id != restaurantDishRelation.RestaurantDishRelationId) { return(NotFound()); } if (ModelState.IsValid) { try { if (restaurantDishRelation.CreatedDateTime.Year < 2000) { restaurantDishRelation.CreatedDateTime = DateTime.Now; } restaurantDishRelation.LastModifiedDateTime = DateTime.Now; _context.Update(restaurantDishRelation); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!RestaurantDishRelationExists(restaurantDishRelation.RestaurantDishRelationId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["DishId"] = new SelectList(_context.Dish, "DishId", "Title", restaurantDishRelation.DishId); var selectList = _context.Restaurant .Include(r => r.Location) .ThenInclude(c => c.Street) .ThenInclude(c => c.District) .ThenInclude(c => c.City) .Select(c => new { RestaurantId = c.RestaurantId, Descr = $"{c.Title} (id:{c.RestaurantId}, {c.Location.Street.District.City.City1})" }); ViewData["RestaurantId"] = new SelectList(selectList, "RestaurantId", "Descr", restaurantDishRelation.RestaurantId); return(View(restaurantDishRelation)); }
public async Task <IActionResult> Edit(int id, [Bind("RestaurantId,Title,Phone,LocationId,CreatedDateTime,LastModifiedDateTime")] Restaurant restaurant) { if (id != restaurant.RestaurantId) { return(NotFound()); } if (ModelState.IsValid) { try { if (restaurant.CreatedDateTime.Year < 2000) { restaurant.CreatedDateTime = DateTime.Now; } restaurant.LastModifiedDateTime = DateTime.Now; _context.Update(restaurant); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!RestaurantExists(restaurant.RestaurantId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } var selectList = _context.Location .Include(c => c.Street) .ThenInclude(c => c.District) .ThenInclude(c => c.City) .Select(c => new { LocationId = c.LocationId, Descr = $"{c.Street.District.City.City1}, {c.Street.District.District1}, " + $"{c.Street.Street1}, {c.BuildingNbr}/{c.Room})" }); ViewData["LocationId"] = new SelectList(selectList, "LocationId", "Descr", restaurant.LocationId); return(View(restaurant)); }
public async Task <IActionResult> Edit(int id, [Bind("DeliveryId,OrderId,CourierId,LocationId,Description,StartTime,EndTime,CreatedDateTime,LastModifiedDateTime,Weight")] Delivery delivery) { if (id != delivery.DeliveryId) { return(NotFound()); } if (ModelState.IsValid) { try { if (delivery.CreatedDateTime.Year < 2000) { delivery.CreatedDateTime = DateTime.Now; } delivery.LastModifiedDateTime = DateTime.Now; _context.Update(delivery); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DeliveryExists(delivery.DeliveryId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["CourierId"] = new SelectList(_context.Courier, "CourierId", "Name", delivery.CourierId); var selectList = _context.Location .Include(c => c.Street) .ThenInclude(c => c.District) .ThenInclude(c => c.City) .Select(c => new { LocationId = c.LocationId, Descr = $"{c.Street.District.City.City1}, {c.Street.District.District1}, " + $"{c.Street.Street1}, {c.BuildingNbr}/{c.Room})" }); ViewData["LocationId"] = new SelectList(selectList, "LocationId", "Descr", delivery.LocationId); ViewData["OrderId"] = new SelectList(_context.Order, "OrderId", "OrderId", delivery.OrderId); return(View(delivery)); }
public async Task <IActionResult> Edit(int id, [Bind("DishId,Title,Quantity,UnitOfMeasureId,DishTypeId,Description,CreatedDateTime,LastModifiedDateTime,Cost")] Dish dish) { if (id != dish.DishId) { return(NotFound()); } if (ModelState.IsValid) { try { if (dish.CreatedDateTime.Year < 2000) { dish.CreatedDateTime = DateTime.Now; } dish.LastModifiedDateTime = DateTime.Now; _context.Update(dish); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DishExists(dish.DishId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["DishTypeId"] = new SelectList(_context.DishType, "DishTypeId", "DishType1", dish.DishTypeId); ViewData["UnitOfMeasureId"] = new SelectList(_context.UnitOfMeasure, "UnitOfMeasureId", "UnitOfMeasure1", dish.UnitOfMeasureId); return(View(dish)); }