示例#1
0
        public async Task <Unit> Handle(UpdateCharterCommand request, CancellationToken cancellationToken)
        {
            _unitOfWork.BeginTransaction();

            try
            {
                var charter = ConvertToCharter(request);

                if (!request.IsDeassignSectionRequest)
                {
                    await _charterRepository.UpdateCharterAsync(charter, request.Company);
                }

                var sectionsAssignedCount = charter.SectionsAssigned.ToList().Count;

                if (sectionsAssignedCount > 0)
                {
                    await _charterRepository.UpdateSectionTrafficAsync(charter, request.Company, request.IsDeassignSectionRequest);
                }

                _unitOfWork.Commit();

                _logger.LogInformation("Charter with id {Atlas_CharterId} updated.", request.CharterId);

                return(Unit.Value);
            }
            catch
            {
                _unitOfWork.Rollback();
                throw;
            }
        }
示例#2
0
 private static Charter ConvertToCharter(UpdateCharterCommand command)
 {
     return(new Charter
     {
         CharterId = command.CharterId,
         CharterCode = command.Reference,
         Description = command.Description,
         VesselId = command.VesselId,
         VesselCode = command.Vessel,
         TransportTypeCode = command.TransportType,
         LoadingLocationCode = command.LoadingLocation,
         DepartureDate = command.DepartureDate,
         DischargeLocationCode = command.DischargeLocation,
         ArrivalDate = command.ArrivalDate,
         SectionsAssigned = command.SectionsAssigned ?? new List <SectionsAssignedToCharterRecord>(),
         CharterManagerId = command.CharterManagerId == 0 ? (long?)null : command.CharterManagerId,
         Memo = command.Memo,
         BlDate = command.BlDate,
         Currency = command.Currency,
         DepartmentId = command.DepartmentId,
         BLRef = command.BLRef,
         WeightUnitId = command.WeightUnitId
     });
 }