Exemple #1
0
        public IActionResult AddOrder([FromForm] AddOrderViewModel orderData)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var        order = orderService.GetById(orderData.OrderId);
                    var        route = routeService.GetById(orderData.RouteId);
                    RouteEntry entry = new RouteEntry()
                    {
                        Id = Guid.NewGuid()
                    };

                    entry.SetOrder(order);
                    entry.SetType(orderData.type);
                    routeService.AddEntry(route.Id.ToString(), entry);
                }
                return(PartialView("_AddOrderPartial", orderData));
            }
            catch (Exception e)
            {
                logger.LogError("Failed to create a new Order {@Exception}", e.Message);
                logger.LogDebug("Failed to create a new Order {@ExceptionMessage}", e);
                return(BadRequest(e.Message));
            }
        }