public void Execute() { var orderChanges = _dataService.GetChanges <Order>().ToList(); var shippingChanges = _dataService.GetChanges <Shipping>().ToList(); var tariffChanges = _dataService.GetChanges <Tariff>().ToList(); var warehouseChanges = _dataService.GetChanges <Warehouse>().ToList(); _dataService.SaveChanges(); RunTriggers(orderChanges); RunTriggers(shippingChanges); RunTriggers(tariffChanges); RunTriggers(warehouseChanges); }
public AppActionResult Run(CurrentUserDto user, Order order) { order.Status = OrderState.Created; order.ShippingStatus = VehicleState.VehicleEmpty; order.DeliveryStatus = VehicleState.VehicleEmpty; var shipping = _dataService.GetById <Shipping>(order.ShippingId.Value); order.ShippingId = null; order.ShippingNumber = null; order.OrderShippingStatus = null; _historyService.Save(order.Id, "orderRemovedFromShipping", order.OrderNumber, shipping.ShippingNumber); var orders = _dataService.GetDbSet <Order>().Where(x => x.ShippingId == shipping.Id && x.Id != order.Id) .ToList(); _historyService.Save(shipping.Id, "orderRemovedFromShipping", order.OrderNumber, shipping.ShippingNumber); _shippingCalculationService.RecalculateShipping(shipping, orders); _shippingGetRouteService.UpdateRoute(shipping, orders); var changes = _dataService.GetChanges <Shipping>().FirstOrDefault(x => x.Entity.Id == shipping.Id); var changeTracker = _changeTrackerFactory.CreateChangeTracker().TrackAll <Shipping>(); changeTracker.LogTrackedChanges(changes); return(new AppActionResult { IsError = false, Message = "orderRemovedFromShipping".Translate(user.Language, order.OrderNumber, shipping.ShippingNumber) }); }