public void AfterChange(ShippingWarehouse entity, string oldValue, string newValue) { var cleanAddress = string.IsNullOrEmpty(newValue) ? null : _cleanAddressService.CleanAddress(newValue); entity.Address = cleanAddress?.ResultAddress ?? entity.Address; entity.PostalCode = cleanAddress?.PostalCode; entity.Region = cleanAddress?.Region; entity.Area = cleanAddress?.Area; entity.City = cleanAddress?.City; entity.Settlement = cleanAddress?.Settlement; entity.Street = cleanAddress?.Street; entity.House = cleanAddress?.House; entity.Block = cleanAddress?.Block; entity.UnparsedParts = cleanAddress?.UnparsedAddressParts; var validStatuses = new[] { OrderState.Created, OrderState.InShipping }; var orders = _dataService.GetDbSet <Order>() .Where(x => x.ShippingWarehouseId == entity.Id && x.ShippingAddress != entity.Address && validStatuses.Contains(x.Status) && (x.ShippingId == null || x.OrderShippingStatus == ShippingState.ShippingCreated)) .ToList(); foreach (var order in orders) { _historyService.SaveImpersonated(null, order.Id, "fieldChanged", nameof(order.ShippingAddress).ToLowerFirstLetter(), order.ShippingAddress, entity.Address); order.ShippingAddress = entity.Address; } }
public void AfterChange(Order order, DateTime?oldValue, DateTime?newValue) { if (order.ShippingId.HasValue) { var ordersToUpdate = _dataService.GetDbSet <Order>().Where(o => o.ShippingId == order.ShippingId && o.Id != order.Id && o.DeliveryWarehouseId == order.DeliveryWarehouseId) .ToList(); foreach (Order updOrder in ordersToUpdate) { updOrder.DeliveryDate = newValue; } } /*if (_isInjection) * { * order.ShippingDate = newValue?.AddDays(0 - order.TransitDays ?? 0); * } * else * { * order.ManualDeliveryDate = true; * }*/ order.OrderChangeDate = DateTime.UtcNow; }
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) }); }
public void AfterChange(Warehouse entity, int?oldValue, int?newValue) { var validStatuses = new[] { OrderState.Created, OrderState.InShipping }; var orders = _dataService.GetDbSet <Order>() .Where(x => x.DeliveryWarehouseId == entity.Id && validStatuses.Contains(x.Status) && (x.ShippingId == null || x.OrderShippingStatus == ShippingState.ShippingCreated)) .ToList(); foreach (var order in orders) { if (order.TransitDays != newValue) { _historyService.SaveImpersonated(null, order.Id, "fieldChanged", nameof(order.TransitDays).ToLowerFirstLetter(), order.TransitDays, newValue); order.TransitDays = newValue; } if (!order.ManualShippingDate && !order.ManualDeliveryDate && !string.IsNullOrEmpty(order.Source)) { DateTime?newShippingDate = order.DeliveryDate?.AddDays(0 - order.TransitDays ?? 0); if (order.ShippingDate != newShippingDate) { _historyService.SaveImpersonated(null, order.Id, "fieldChanged", nameof(order.ShippingDate).ToLowerFirstLetter(), order.ShippingDate, newShippingDate); order.ShippingDate = newShippingDate; } } } }
public void AfterChange(Order order, Guid?oldValue, Guid?newValue) { if (order.ShippingId != null) { string oldName = oldValue == null ? null : _dataService.GetById <TransportCompany>(oldValue.Value)?.Title; string newName = newValue == null ? null : _dataService.GetById <TransportCompany>(newValue.Value)?.Title; var shipping = _dataService.GetById <Shipping>(order.ShippingId.Value); if (shipping != null) { shipping.CarrierId = newValue; _historyService.Save(shipping.Id, "fieldChanged", nameof(shipping.CarrierId).ToLowerFirstLetter(), oldName, newName); } var otherOrders = _dataService.GetDbSet <Order>().Where(x => x.ShippingId == order.ShippingId && x.Id != order.Id).ToList(); foreach (var otherOrder in otherOrders) { otherOrder.CarrierId = newValue; _historyService.Save(otherOrder.Id, "fieldChanged", nameof(otherOrder.CarrierId).ToLowerFirstLetter(), oldName, newName); } } }
public ExcelMapper(ICommonDataService dataService, IUserProvider userProvider, IFieldDispatcherService fieldDispatcherService) { _userProvider = userProvider; _fieldDispatcherService = fieldDispatcherService; _translations = dataService.GetDbSet <Translation>().ToList(); InitColumns(); }
public void Execute(Order entity) { if (entity.ShippingId.HasValue) { var entityShippingId = entity.ShippingId.Value; var shipping = _dataService.GetById <Shipping>(entityShippingId); var orders = _dataService.GetDbSet <Order>() .Where(x => x.ShippingId == entityShippingId); foreach (var orderInShipping in orders) { if (orderInShipping.TarifficationType != entity.TarifficationType) { _historyService.Save(orderInShipping.Id, "fieldChangedBy", nameof(entity.TarifficationType).ToLowerFirstLetter(), orderInShipping.TarifficationType, entity.TarifficationType, "onChangeInOtherOrderInShipping"); orderInShipping.TarifficationType = entity.TarifficationType; } } if (shipping.TarifficationType != entity.TarifficationType) { _historyService.Save(shipping.Id, "fieldChangedBy", nameof(shipping.TarifficationType).ToLowerFirstLetter(), shipping.TarifficationType, entity.TarifficationType, "onChangeInIncludedOrder"); shipping.TarifficationType = entity.TarifficationType; _calcService.UpdateDeliveryCost(shipping); } } }
public void AfterChange(Order order, DateTime?oldValue, DateTime?newValue) { if (order.ShippingId.HasValue) { //var ordersToUpdate = _dataService.GetDbSet<Order>().Where(o => o.ShippingId == order.ShippingId // && o.Id != order.Id // && o.ShippingWarehouseId == order.ShippingWarehouseId) // .ToList(); //foreach (Order updOrder in ordersToUpdate) //{ // var setter = new FieldSetter<Order>(updOrder, _historyService); // setter.UpdateField(o => o.LoadingDepartureTime, newValue); // setter.SaveHistoryLog(); //} var shipping = _dataService.GetById <Shipping>(order.ShippingId.Value); if (shipping != null) { var orders = _dataService.GetDbSet <Order>() .Where(o => o.ShippingId == order.ShippingId && o.Id != order.Id) .ToList(); orders.Add(order); var loadingDepartureTime = orders.Select(i => i.LoadingDepartureTime).Where(i => i != null).Min(); shipping.LoadingDepartureTime = loadingDepartureTime; } } }
public VerificationResultWith <TokenModel> GetToken(IdentityModel model) { prepareIdentityModelBeforeLogin(model); var user = _dataService.GetDbSet <User>().GetByLogin(model.Login); if (user != null && !user.IsActive) { return new VerificationResultWith <TokenModel> { Result = VerificationResult.Forbidden, Data = null } } ; var identity = GetIdentity(model.Login, model.Password, model.Language); return(GetTokenInner(user, identity)); }
public ExcelDoubleMapper(ICommonDataService dataService, IUserProvider userProvider, IFieldDispatcherService fieldDispatcherService, string innerFieldName) { _userProvider = userProvider; _fieldDispatcherService = fieldDispatcherService; _translations = dataService.GetDbSet <Translation>().ToList(); _innerFieldName = innerFieldName; InitColumns(); }
public void Execute(Order entity) { if (entity.ShippingId != null) { var shipping = _dataService.GetById <Shipping>(entity.ShippingId.Value); var orders = _dataService.GetDbSet <Order>().Where(_ => _.ShippingId == entity.ShippingId); _getRouteService.UpdateRoute(shipping, orders); } }
public ValidateResult CreateDocument(Guid id, DocumentDto dto) { //TEntity entity = this.dataService.GetById<TEntity>(id); //if (entity == null) //{ // return new ValidateResult("notFound"); //} bool tryParseFileId = Guid.TryParse(dto.FileId, out Guid fileId); FileStorage file = dataService.GetDbSet <FileStorage>().FirstOrDefault(x => x.Id == fileId); if (!tryParseFileId || file == null) { return(new ValidateResult("notFound")); } Guid?typeId = null; if (!string.IsNullOrEmpty(dto.TypeId) && Guid.TryParse(dto.TypeId, out Guid tId)) { typeId = tId; } var document = new Document { Name = dto.Name, PersistableId = id, FileId = fileId, TypeId = typeId }; _historyService.Save(id, "documentAttached", file.Name); dataService.GetDbSet <Document>().Add(document); dataService.SaveChanges(); return(new ValidateResult { Id = document.Id.ToString() }); }
public AppActionResult Run(CurrentUserDto user, Shipping shipping) { if (shipping.CarrierId == null) { return new AppActionResult { IsError = true, Message = "shippingDontSetRequestSentDontSetTk".Translate(user.Language, shipping.ShippingNumber) } } ; var transportCompany = _dataService.GetById <TransportCompany>(shipping.CarrierId.Value); var currentUser = _dataService.GetById <User>(user.Id.Value); if (transportCompany.Title == "FM Logistic" && currentUser.IsFMCPIntegrated()) { using (var fmcp = new FMCPIntegration(currentUser, _dataService)) { var fmcpWaybillId = fmcp.CreateWaybill(shipping); _historyService.Save(shipping.Id, "shippingSetRequestSent", shipping.ShippingNumber); shipping.FmcpWaybillId = fmcpWaybillId; } } shipping.Status = ShippingState.ShippingRequestSent; foreach (var order in _dataService.GetDbSet <Order>().Where(o => o.ShippingId == shipping.Id)) { order.OrderShippingStatus = shipping.Status; } _historyService.Save(shipping.Id, "shippingSetRequestSent", shipping.ShippingNumber); return(new AppActionResult { IsError = false, Message = "shippingSetRequestSent".Translate(user.Language, shipping.ShippingNumber) }); }
public AppActionResult Run(CurrentUserDto user, Order order) { string orderNumber = order.OrderNumber; ///TODO: заменить на использованием флага IsActive после реализации фильтров (нужно будет прокидывать условие, что отбираем только активные для грида) var itemsDbSet = _dataService.GetDbSet <OrderItem>(); itemsDbSet.RemoveRange(itemsDbSet.Where(x => x.OrderId == order.Id)); var historyDbSet = _dataService.GetDbSet <HistoryEntry>(); historyDbSet.RemoveRange(historyDbSet.Where(x => x.PersistableId == order.Id)); _dataService.GetDbSet <Order>().Remove(order); return(new AppActionResult { IsError = false, Message = "orderRemoved".Translate(user.Language, orderNumber) }); }
public void AfterChange(Order order, Guid?oldValue, Guid?newValue) { if (order.ShippingWarehouseId.HasValue) { var shippingWarehouse = _dataService.GetDbSet <ShippingWarehouse>().Find(order.ShippingWarehouseId.Value); if (shippingWarehouse != null) { order.ShippingAddress = shippingWarehouse.Address; order.ShippingCity = shippingWarehouse.City; } } }
public AppActionResult Run(CurrentUserDto user, Shipping shipping) { var orders = _dataService.GetDbSet <Order>() .Where(x => x.ShippingId.HasValue && x.ShippingId.Value == shipping.Id).ToList(); var ordersIds = _dataService.GetDbSet <Order>() .Where(x => x.ShippingId.HasValue && x.ShippingId.Value == shipping.Id) .Select(_ => _.Id).ToArray(); var itemsDbSet = _dataService.GetDbSet <OrderItem>(); itemsDbSet.RemoveRange(itemsDbSet.Where(x => ordersIds.Contains(x.OrderId))); var historyDbSet = _dataService.GetDbSet <HistoryEntry>(); historyDbSet.RemoveRange(historyDbSet.Where(x => ordersIds.Contains(x.PersistableId))); _dataService.GetDbSet <Order>().RemoveRange(orders); _dataService.GetDbSet <Shipping>().Remove(shipping); historyDbSet.RemoveRange(historyDbSet.Where(x => x.PersistableId == shipping.Id)); _historyService.Save(shipping.Id, "deleteShipping", shipping.ShippingNumber); return(new AppActionResult { IsError = false, Message = "shippingDeleted".Translate(user.Language, shipping.ShippingNumber) }); }
public ProfileDto GetProfile() { var currentUserId = _userProvider.GetCurrentUserId(); var user = _dataService .GetDbSet <User>() .GetById(currentUserId.Value); var role = _dataService .GetDbSet <Role>() .GetById(user.RoleId); return(new ProfileDto { Email = user.Email, UserName = user.Name, RoleName = role.Name, PoolingLogin = user.PoolingLogin, PoolingPassword = user.PoolingPassword, FmCPLogin = user.FmCPLogin, FmCPPassword = user.FmCPPassword }); }
public IEnumerable <LookUpDto> ForSelect() { return(_dataService.GetDbSet <Warehouse>() .Select(i => i.City) .Where(i => !string.IsNullOrWhiteSpace(i)) .Distinct() .Select(i => new LookUpDto { Value = i, Name = i }) .ToList()); }
public void Execute(Tariff tariff) { var shippings = _dataService.GetDbSet <Shipping>() .Where(x => x.Status == ShippingState.ShippingCreated || x.Status == ShippingState.ShippingRequestSent || x.Status == ShippingState.ShippingRejectedByTc) .ToList(); foreach (var shipping in shippings) { _calcService.UpdateDeliveryCost(shipping); } }
public void AfterChange(Order order, VehicleState oldValue, VehicleState newValue) { if (order.ShippingId.HasValue) { var ordersToUpdate = _dataService.GetDbSet <Order>().Where(o => o.ShippingId == order.ShippingId && o.Id != order.Id && o.DeliveryWarehouseId == order.DeliveryWarehouseId) .ToList(); foreach (Order updOrder in ordersToUpdate) { updOrder.DeliveryStatus = newValue; } } }
public void Execute(Warehouse shipping) { string rawAddress = $"{shipping.City} {shipping.Address}"; var cleanAddress = string.IsNullOrEmpty(rawAddress) ? null : _cleanAddressService.CleanAddress(rawAddress); shipping.ValidAddress = cleanAddress?.ResultAddress; shipping.PostalCode = cleanAddress?.PostalCode; shipping.Region = cleanAddress?.Region; shipping.City = cleanAddress?.City; shipping.Area = cleanAddress?.Area; shipping.Street = cleanAddress?.Street; shipping.House = cleanAddress?.House; shipping.UnparsedAddressParts = cleanAddress?.UnparsedAddressParts; var validStatuses = new[] { OrderState.Created, OrderState.InShipping }; var orders = _dataService.GetDbSet <Order>() .Where(x => x.DeliveryWarehouseId == shipping.Id && validStatuses.Contains(x.Status) && (x.ShippingId == null || x.OrderShippingStatus == ShippingState.ShippingCreated)) .ToList(); foreach (var order in orders) { if (order.DeliveryAddress != shipping.Address) { _historyService.SaveImpersonated(null, order.Id, "fieldChanged", nameof(order.DeliveryAddress).ToLowerFirstLetter(), order.DeliveryAddress, shipping.Address); order.DeliveryAddress = shipping.Address; } if (order.DeliveryRegion != shipping.Region) { _historyService.SaveImpersonated(null, order.Id, "fieldChanged", nameof(order.DeliveryRegion).ToLowerFirstLetter(), order.DeliveryRegion, shipping.Region); order.DeliveryRegion = shipping.Region; } if (order.DeliveryCity != shipping.City) { _historyService.SaveImpersonated(null, order.Id, "fieldChanged", nameof(order.DeliveryCity).ToLowerFirstLetter(), order.DeliveryCity, shipping.City); order.DeliveryCity = shipping.City; } } }
public IEnumerable <LookUpDto> ForSelect() { var entities = _dataService.GetDbSet <ShippingWarehouse>() .Where(x => !string.IsNullOrEmpty(x.Address)) .OrderBy(x => x.Address) .ToList(); foreach (var entity in entities) { yield return(new LookUpDto { Name = entity.Address, Value = entity.Id.ToString() }); } }
public void AfterChange(ShippingWarehouse entity, string oldValue, string newValue) { var validStatuses = new[] { OrderState.Created, OrderState.InShipping }; var orders = _dataService.GetDbSet <Order>() .Where(x => x.ShippingWarehouseId == entity.Id && validStatuses.Contains(x.Status) && (x.ShippingId == null || x.OrderShippingStatus == ShippingState.ShippingCreated)) .ToList(); foreach (var order in orders) { _historyService.SaveImpersonated(null, order.Id, "fieldChanged", nameof(order.ShippingWarehouseId).ToLowerFirstLetter(), oldValue, newValue); } }
public void AfterChange(Warehouse entity, TimeSpan?oldValue, TimeSpan?newValue) { var validStatuses = new[] { OrderState.Created }; var orders = _dataService.GetDbSet <Order>() .Where(x => x.DeliveryWarehouseId == entity.Id && validStatuses.Contains(x.Status) && !x.ManualClientAvisationTime) .Where(x => !x.ManualClientAvisationTime) .ToList(); foreach (var order in orders) { _historyService.SaveImpersonated(null, order.Id, "fieldChanged", nameof(order.ClientAvisationTime).ToLowerFirstLetter(), order.ClientAvisationTime, newValue); order.ClientAvisationTime = newValue; } }
public AppActionResult Run(CurrentUserDto user, Shipping shipping) { shipping.Status = ShippingState.ShippingArhive; foreach (var order in _dataService.GetDbSet <Order>().Where(o => o.ShippingId == shipping.Id)) { order.OrderShippingStatus = shipping.Status; } _historyService.Save(shipping.Id, "shippingSetArchived", shipping.ShippingNumber); return(new AppActionResult { IsError = false, Message = "shippingSetArchived".Translate(user.Language, shipping.ShippingNumber) }); }
public void AfterChange(Shipping shipping, Guid?oldValue, Guid?newValue) { var oldName = oldValue == null ? null : _dataService.GetById <TransportCompany>(oldValue.Value)?.Title; var newName = newValue == null ? null : _dataService.GetById <TransportCompany>(newValue.Value)?.Title; var orders = _dataService.GetDbSet <Order>() .Where(x => x.ShippingId == shipping.Id) .ToList(); foreach (var order in orders) { _historyService.Save(order.Id, "fieldChanged", nameof(order.CarrierId).ToLowerFirstLetter(), oldName, newName); order.CarrierId = newValue; } }
public void AfterChange(Article entity, string oldValue, string newValue) { var validStatuses = new[] { OrderState.Created, OrderState.InShipping, OrderState.Shipped, OrderState.Delivered }; var itemsToUpdate = _dataService.GetDbSet <OrderItem>() .Include(x => x.Order) .Where(x => x.Nart == entity.Nart && x.Order != null && x.Description != newValue && validStatuses.Contains(x.Order.Status)) .ToList(); foreach (var orderItem in itemsToUpdate) { orderItem.Description = newValue; _historyService.SaveImpersonated(null, orderItem.OrderId, "orderItemChangeDescription", orderItem.Nart, newValue); } }
public AppActionResult Run(CurrentUserDto user, Shipping shipping) { var newState = new ShippingState?(); if (shipping.Status == ShippingState.ShippingCompleted) { newState = ShippingState.ShippingConfirmed; } if (shipping.Status == ShippingState.ShippingBillSend) { newState = ShippingState.ShippingCompleted; } if (shipping.Status == ShippingState.ShippingArhive) { newState = ShippingState.ShippingBillSend; } if (newState.HasValue) { shipping.Status = newState.Value; foreach (var order in _dataService.GetDbSet <Order>().Where(o => o.ShippingId == shipping.Id)) { order.OrderShippingStatus = shipping.Status; } _historyService.Save(shipping.Id, "shippingRollback", shipping.ShippingNumber, newState.ToString().ToLowerFirstLetter()); } string newStateName = newState?.ToString()?.ToLowerFirstLetter().Translate(user.Language); return(new AppActionResult { IsError = false, Message = "shippingRollback".Translate(user.Language, shipping.ShippingNumber, newStateName) }); }
public void Execute(Shipping entity) { var orders = _dataService.GetDbSet <Order>() .Where(x => x.ShippingId == entity.Id); foreach (var orderInShipping in orders) { if (orderInShipping.TarifficationType != entity.TarifficationType) { _historyService.Save(orderInShipping.Id, "fieldChangedBy", nameof(entity.TarifficationType).ToLowerFirstLetter(), orderInShipping.TarifficationType, entity.TarifficationType, "onChangeInShipping"); orderInShipping.TarifficationType = entity.TarifficationType; } } _calcService.UpdateDeliveryCost(entity); UpdateShippingFromIntegrations(entity); }
public IEnumerable <LookUpDto> ForSelect(string clientId, string deliveryCity) { Guid?clientIdValue = clientId.ToGuid(); var entities = _dataService.GetDbSet <Warehouse>() .Where(x => !string.IsNullOrEmpty(x.Address) && (clientIdValue == null || x.ClientId == clientIdValue) && (string.IsNullOrEmpty(deliveryCity) || x.City == deliveryCity)) .OrderBy(x => x.Address) .ToList(); foreach (var entity in entities) { yield return(new LookUpDto { Name = entity.Address, Value = entity.Id.ToString() }); } }