Exemplo n.º 1
0
        public OperationResponse <bool> UpdateOrderStatus(orderStatusModel orderStatusModel)
        {
            OperationResponse <bool> or = new OperationResponse <bool>();

            try
            {
                if (orderStatusModel.HeaderId == 0 || orderStatusModel.SalesRepId == "")
                {
                    throw new Exception("insert UserId Or HeaderId");
                }
                //get headers with client id  and details with headerID
                // get customer headers of orders
                var order = context.PoscurrentDailyTransHeader.FirstOrDefault(i => i.HeaderId == orderStatusModel.HeaderId && i.SalesRepId == orderStatusModel.SalesRepId);
                if (order != null)
                {
                    order.FkDeliveryStatusId = orderStatusModel.FkDeliveryStatusId;
                    if (orderStatusModel.FkDeliveryStatusId == 4)
                    {
                        order.InsDeliveryClosed = DateTime.Now.ToString();
                    }
                    else
                    {
                        order.InsDeliverySent = DateTime.Now.ToString();
                    }
                    int rowsEffected = context.SaveChanges();
                    or.HasErrors  = false;
                    or.StatusCode = "200";
                    or.Data       = true;
                }
                else
                {
                    throw new Exception("Order not found");
                }
            }
            catch (Exception ex)
            {
                or.HasErrors = true;
                or.Message   = ex.Message;
                or.Data      = false;
            }
            return(or);
        }
        public IActionResult UpdateOrderStatus([FromBody]  orderStatusModel orderStatusModel)
        {
            var res = _orderService.UpdateOrderStatus(orderStatusModel);

            return(resultWithStatus(res));
        }