public async Task <ActionResult> UpdateOrder(int id, CustomerOrderForUpdateDto updates) { try { if (!Enum.IsDefined(typeof(CustomerOrderStatus), updates.Status)) { return(BadRequest("Status doesn't exist")); } CustomerOrder order = await dbContext.CustomerOrders.Where(co => co.Id == id) .Include(co => co.Customer) .Include(co => co.OrderItems) .ThenInclude(oi => oi.Product) .FirstOrDefaultAsync(); if (order == null) { return(NotFound($"Order with Id: {id} not found")); } order.Status = updates.Status; dbContext.CustomerOrders.Update(order); await dbContext.SaveChangesAsync(); return(Ok(new Response <CustomerOrderFullDto>(mapper.Map <CustomerOrderFullDto>(order)))); } catch { return(StatusCode(StatusCodes.Status500InternalServerError)); } }
public async Task <Response <CustomerOrderFullDto> > EditOrder(string id, CustomerOrderForUpdateDto order) { try { return(await httpClient.PutJsonAsync <Response <CustomerOrderFullDto> >("api/customerorders/" + id, order)); } catch { return(null); } }
protected override async Task OnInitializedAsync() { IsLoading = true; var result = await CustomerOrderService.GetOrder(Id); Order = result.Data; OrderUpdate = new CustomerOrderForUpdateDto() { Status = Order.Status }; IsLoading = false; }