public Task UpdateAsync( StockArrival arrival, Dictionary <string, string> headers = default, CancellationToken ct = default) { return(_factory.PatchAsync(_host + "/Stock/Arrivals/v1/Update", null, arrival, headers, ct)); }
public async Task <Guid> CreateAsync(Guid userId, StockArrival arrival, CancellationToken ct) { var newStockArrival = new StockArrival(); var change = newStockArrival.CreateWithLog(userId, x => { x.Id = arrival.Id; x.AccountId = arrival.AccountId; x.CreateUserId = userId; x.Type = arrival.Type; x.SupplierId = arrival.SupplierId; x.OrderId = arrival.OrderId; x.InventoryId = arrival.InventoryId; x.IsDeleted = arrival.IsDeleted; x.CreateDateTime = DateTime.UtcNow; x.Items = arrival.Items.Map(x.Id); }); var entry = await _storage.AddAsync(newStockArrival, ct); await _storage.AddAsync(change, ct); await _storage.SaveChangesAsync(ct); return(entry.Entity.Id); }
public async Task <ActionResult <Guid> > Create(StockArrival arrival, CancellationToken ct = default) { arrival.AccountId = _userContext.AccountId; var id = await _stockArrivalsService.CreateAsync(_userContext.UserId, arrival, ct); return(Created(nameof(Get), id)); }
public StockArrivalBuilder( IDefaultRequestHeadersService defaultRequestHeadersService, IStockArrivalsClient arrivalsClient) { _arrivalsClient = arrivalsClient; _defaultRequestHeadersService = defaultRequestHeadersService; _arrival = new StockArrival { Id = Guid.NewGuid(), Type = StockArrivalType.ArrivalFromSupplier, IsDeleted = false }; }
public async Task <ActionResult> Update(StockArrival arrival, CancellationToken ct = default) { var oldArrival = await _stockArrivalsService.GetAsync(arrival.Id, true, ct); if (oldArrival == null) { return(NotFound(arrival.Id)); } return(await ActionIfAllowed( () => _stockArrivalsService.UpdateAsync(_userContext.UserId, oldArrival, arrival, ct), Roles.Stock, oldArrival.AccountId)); }
public static StockArrivalChange CreateWithLog( this StockArrival arrival, Guid userId, Action <StockArrival> action) { action(arrival); return(new StockArrivalChange { StockArrivalId = arrival.Id, ChangerUserId = userId, CreateDateTime = DateTime.UtcNow, OldValueJson = string.Empty, NewValueJson = arrival.ToJsonString() }); }
public static bool FilterByAdditional(this StockArrival arrival, StockArrivalGetPagedListRequest request) { return((request.Types == null || !request.Types.Any() || request.Types.Any(x => TypesPredicate(arrival, x))) && (request.CreateUserIds == null || !request.CreateUserIds.Any() || request.CreateUserIds.Any(x => CreateUserIdsPredicate(arrival, x))) && (request.SupplierIds == null || !request.SupplierIds.Any() || request.SupplierIds.Any(x => SupplierIdsPredicate(arrival, x))) && (request.OrderIds == null || !request.OrderIds.Any() || request.OrderIds.Any(x => OrderIdsPredicate(arrival, x))) && (request.InventoryIds == null || !request.InventoryIds.Any() || request.InventoryIds.Any(x => InventoryIdsPredicate(arrival, x))) && (request.ItemsRoomIds == null || !request.ItemsRoomIds.Any() || request.ItemsRoomIds.Any(x => ItemsRoomIdsPredicate(arrival, x))) && (request.ItemsProductIds == null || !request.ItemsProductIds.Any() || request.ItemsProductIds.Any(x => ItemsProductIdsPredicate(arrival, x)))); }
public async Task UpdateAsync( Guid userId, StockArrival oldArrival, StockArrival newArrival, CancellationToken ct) { var change = oldArrival.UpdateWithLog(userId, x => { x.AccountId = newArrival.AccountId; x.Type = newArrival.Type; x.SupplierId = newArrival.SupplierId; x.OrderId = newArrival.OrderId; x.InventoryId = newArrival.InventoryId; x.IsDeleted = newArrival.IsDeleted; x.ModifyDateTime = DateTime.UtcNow; x.Items = newArrival.Items.Map(x.Id); }); _storage.Update(oldArrival); await _storage.AddAsync(change, ct); await _storage.SaveChangesAsync(ct); }
private static bool ItemsProductIdsPredicate(StockArrival arrival, Guid id) { return(arrival.Items == null || !arrival.Items.Any() || arrival.Items.Any(x => x.ProductId == id)); }
private static bool CreateUserIdsPredicate(StockArrival arrival, Guid id) { return(arrival.CreateUserId == id); }
private static bool InventoryIdsPredicate(StockArrival arrival, Guid id) { return(arrival.InventoryId == id); }
private static bool OrderIdsPredicate(StockArrival arrival, Guid id) { return(arrival.OrderId == id); }
private static bool SupplierIdsPredicate(StockArrival arrival, Guid id) { return(arrival.SupplierId == id); }
private static bool TypesPredicate(StockArrival arrival, StockArrivalType type) { return(arrival.Type == type); }