public Response <Category> UpdateCategory(UpdateCategoryRequest request) { var CategoryQuery = _context.Category.Where(w => w.Id == request.Id); if (CategoryQuery.FirstOrDefault() == null) { return(new Response <Category>() { Status = System.Net.HttpStatusCode.NoContent, Message = "Id Not found" }); } ; var Category = CategoryQuery.FirstOrDefault(); Category.CategoryName = request.CategoryName; _context.Entry(Category).State = EntityState.Modified; _context.SaveChanges(); return(new Response <Category>()); }
public Response <Menu> UpdateMenu(UpdateMenuRequest request) { var menuQuery = _context.Menu.Where(w => w.Id == request.Id); if (menuQuery.FirstOrDefault() == null) { return(new Response <Menu>() { Status = System.Net.HttpStatusCode.NoContent, Message = "Id Not found" }); } ; var menu = menuQuery.FirstOrDefault(); menu.MenuName = request.MenuName; menu.Price = request.Price; menu.CategoryId = request.CategoryId; _context.Entry(menu).State = EntityState.Modified; _context.SaveChanges(); return(new Response <Menu>()); }
public Response <Order> UpdateOrder(UpdateOrderRequest request) { var orderQuery = _context.Order.Where(w => w.Id == request.Id); if (orderQuery.FirstOrDefault() == null) { return(new Response <Order>() { Status = System.Net.HttpStatusCode.NoContent, Message = "Id Not found" }); } ; var order = orderQuery.FirstOrDefault(); order.OrderName = request.OrderName; order.Total = _getTotal(request); order.OrderDate = request.OrderDate; _context.Entry(order).State = EntityState.Modified; _context.SaveChanges(); return(new Response <Order>()); }