Esempio n. 1
0
        public async Task <int> CreateAsync(ShipmentDTO item)
        {
            item.DateTime = DateTime.Now;
            int shipmentId = await _repo.CreateAsync(_mapper.Map <Shipment>(item));

            var shipment = await ReadAsync(shipmentId);

            if (shipment.Order.UserId == item.RepicientApplicationUserId)
            {
                await _statusesService.SetDelivered(shipment.OrderId, null);
            }
            else if (shipment.Repicient.UserName.Contains("Courier", StringComparison.OrdinalIgnoreCase))
            {
                await _statusesService.SetByStatusString(shipment.OrderId, "Передан курьеру", null);
            }

            return(shipmentId);
        }