Exemplo n.º 1
0
        public async Task <IActionResult> CancelUserOrder(int orderId, [FromBody] OrderForUpdateDto orderForUpdateDto)
        {
            if (Request.Headers.ContainsKey("id"))
            {
                if (int.Parse(Request.Headers["id"].First()) == int.Parse(User.FindFirst(ClaimTypes.NameIdentifier)?.Value))
                {
                    var order = await _repo.GetOrderById(orderId);

                    order.OrderStatus = orderForUpdateDto.OrderStatus;

                    if (await _repo.SaveAll())
                    {
                        return(NoContent());
                    }
                }
            }
            return(Unauthorized("id not match or not found"));
        }