public async Task <ContainerDto> CreateOrUpdateAsync(ContainerDto input, ContainerInfoDto containerInfo) { ArriveOfDespatch entity = await GetArriveOfDespatchbyContainerId(input.ContainerId); if (entity != null) { entity.OriginPort = containerInfo.OriginPort; entity.DestinationPort = containerInfo.DestinationPort; entity.Mode = containerInfo.Mode; entity.Carrier = containerInfo.Carrier; _arriveOfDespatchRepository.Update(entity); } else { entity = Mapper.Map <ArriveOfDespatch>(input); entity.OriginPort = containerInfo.OriginPort; entity.DestinationPort = containerInfo.DestinationPort; entity.Mode = containerInfo.Mode; entity.Carrier = containerInfo.Carrier; entity.Id = 0; entity.RowVersion = null; _arriveOfDespatchRepository.Insert(entity); } await UpdateContainer(input.ContainerId); await UnitOfWork.SaveChangesAsync(); return(Mapper.Map <ContainerDto>(entity)); }
private async Task <List <ContainerDto> > ConvertToResultAsync(List <Container> input) { List <ContainerDto> result = new List <ContainerDto>(); foreach (var item in input) { ContainerDto output = new ContainerDto(); Booking booking = await _shipmentBookingDataProvider.GetByIdAsync((item.Manifests.ToList())[0].BookingId); List <ArriveOfDespatch> arriveOfDespatch = await _arriveOfDespatchRepository.Query(x => x.ContainerId == item.Id, false).SelectAsync(); List <Manifest> manifests = item.Manifests.ToList(); DateTime minETD = DateTime.MaxValue; DateTime minETA = DateTime.MaxValue; foreach (var manifestItem in manifests) { Booking book = await _shipmentBookingDataProvider.GetByIdAsync(manifestItem.BookingId); if (book.ETA < minETA) { minETA = book.ETA; } if (book.ETD < minETD) { minETD = book.ETD; } } if (item.Status == ContainerStatus.Pending) { output = Mapper.Map <ContainerDto>(booking); output.ETA = minETA; output.ETD = minETD; output.OriginPort = booking.PortOfLoading; output.DestinationPort = booking.PortOfDelivery; } else if (item.Status == ContainerStatus.Despatch) { output = Mapper.Map <ContainerDto>(arriveOfDespatch[0]); } //output = Mapper.Map<ContainerDto>(item); output.Name = item.Name; output.Size = item.Size; output.Status = item.Status; output.ContainerId = item.Id; output.BookingId = booking.Id; result.Add(output); } result = result.OrderBy(p => p.OriginPort).ThenBy(p => p.DestinationPort).ThenBy(p => p.Mode).ThenBy(p => p.Carrier).ThenBy(p => p.ETD).ThenBy(p => p.ETA).ThenBy(p => p.Name).ToList(); //return Sort(result); return(result); }
public async Task Test_IndexServiceNeverDuplicatesPathMasterRecords() { var _connection = new SqliteConnection("DataSource=:memory:"); _connection.Open(); var options = new DbContextOptionsBuilder <DbCtxt>() .UseSqlite(_connection) .EnableSensitiveDataLogging(true) .Options; var dbc = new DbCtxt(options); await dbc.Database.EnsureCreatedAsync(); var r = new IndexDbRepo(dbc, _logger); var indexService = new IndexService(r); var container = new ContainerDto { ContainerNumber = new ContainerNumberDto() { Number = "bcdefghijklmnopqrstuvwxyabcdefghijklmnopqrstuvwxz :123456789012345678901234567890 12345678901234567890 12345678901234567890123456789012bcdefghijklmnopqrst uvwxyabcdefghijklmnopqrstuvwxz:12345678901234 567890123456789012345678 901234567890123456 78901234567890123456789012" }, AssignedTo = new ContainerDto.CarrierDto { Code = "aby", Name = "name", phones = new string[] { "bcdefghijklmnopqrstuvwxyabcdefghijklmnopqrstuvwxz:1234567890123456789012345678901234567890123456789012345678901234567890123456789012bcdefghijklmnopqrstuvwxyabcdefghijklmnopqrstuvwxz:1234567890123456789012345678901234567890123456789012345678901234567890123456789012" } } }; var cmd = indexService.CreateUpdateCommand("0001", container); await indexService.Handle(cmd); var attchs = new List <AttachmentDto>(); attchs.Add(new AttachmentDto { Type = "invoice", DownloadUrl = "hdhjdhjhsa" }); container.Attachments = attchs.ToArray(); var cmd2 = indexService.CreateUpdateCommand("0001", container); await indexService.Handle(cmd2); attchs.Add(new AttachmentDto { Type = "invoice3", DownloadUrl = "hdhjdhjhsa3" }); container.Attachments = attchs.ToArray(); var cmd3 = indexService.CreateUpdateCommand("0001", container); await indexService.Handle(cmd3); var paths = dbc.Set <DbDocSourcePath>().Select(p => p).Where(p => p.PathString == "$.Attachments.[].DownloadUrl").ToArray(); var tokens = dbc.Set <DbDocToken>().Select(t => t).ToArray(); // load paths from database //var paths = await dbc.Set<DbDocSourcePath>().Where(p=>p.PathString == "$.Attachments.[].DownloadUrl").ToArrayAsync(); Assert.AreEqual(1, paths.Length); }
public static async Task RemoveRowAsync(this ContainerDto container, List <ComponentDto> row) { if (container.Rows.Count > 1) { container.Rows.Remove(row); } await Task.CompletedTask; }
public IActionResult GetContainer([FromBody] ContainerDto containerDto) { try { var container = _mapper.Map <Container>(containerDto); _repositoryManager.Container.UpdateContainer(container); _repositoryManager.Save(); return(Ok()); }catch (Exception e) { return(BadRequest(e.Message)); } }
public BeerContainerDto( Beer beer, Container container, TemperatureAlert temperatureAlert ) { Beer = new BeerDto(beer); Container = new ContainerDto(container); if (temperatureAlert != null) { TemperatureAlert = new TemperatureAlertDto(temperatureAlert); } }
public async Task <IActionResult> PutContainer(int id, ContainerDto containerDto) { try { var container = _mapper.Map <Container>(containerDto); await _repo.UpdateContainer(id, container); return(Ok("Container was updated")); } catch (Exception e) { return(Ok(e.Message)); } }
public async Task <IActionResult> PostContainer(ContainerDto containerDto) { try { var container = _mapper.Map <Container>(containerDto); container.IsActive = true; await _repo.CreateContainer(container); return(Ok("Container was Created!")); } catch (Exception e) { return(Ok(e.Message)); } }
public async Task <ContainerDto> BuildContainer( List <ComponentDto> componentList) { ContainerDto container = null; if (componentList == null || componentList.Count == 0) { container = new ContainerDto(); return(await Task.FromResult(container)); } var rootComponents = GetRootComponents(componentList, null); return(await Task.FromResult(container)); }
public bool SameGroup(ContainerDto first, ContainerDto second) { for (int property = 0; property < 6; property++) { var currentProperty = typeof(ContainerDto).GetProperties()[property]; string firstValue = currentProperty.GetValue(first).ToString(); string secondValue = currentProperty.GetValue(second).ToString(); if (firstValue.CompareTo(secondValue) != 0) { return(false); } } return(true); }
public void TestVisitor() { var container = new ContainerDto { Attachments = new AttachmentDto[] { new AttachmentDto { }, new AttachmentDto { } } }; var contentNode = ContentFactory.Default.CreateFrom(container); var pairs = contentNode.Visit(); }
private IList <ContainerDto> GenerateContainers(int numberOfContainers, int numberOfImages) { string containerDefaultName = "var{0}"; var containerList = new List <ContainerDto>(); for (int i = 0; i < numberOfContainers; i++) { var container = new ContainerDto { ContainerName = string.Format(containerDefaultName, containerIndex.ToString()) }; container.ImageList = GenerateImageList(numberOfImages); containerList.Add(container); containerIndex++; } return(containerList); }
public static bool IsEmpty(this ContainerDto container) { bool result = true; if (container != null && container.Rows.Any()) { foreach (var row in container.Rows) { if (row != null && row.Any()) { result = false; break; } } } return(result); }
public IList <ContainerDto> GetSortedImages(IList <IExifDataDto> images) { var containerList = new List <ContainerDto>(); ContainerDto container = new ContainerDto();; int containerNameIndex = 1; DateTime prevImageDateTime = DateTime.MinValue; int prevIsoLevel = 0; for (int i = 0; i < images.Count; i++) { var isInNewSequence = GetIsInNewSequence( prevImageDateTime, images[i].TakenDateTime, prevIsoLevel, images[i].IsoLevel); if (isInNewSequence) { if (i > 0) { containerList.Add(container); container = new ContainerDto(); containerNameIndex++; } container.ContainerName = $"{CONTAINER_NAME}{containerNameIndex}"; } container.ImageList.Add(images[i]); prevImageDateTime = images[i].TakenDateTime; prevIsoLevel = images[i].IsoLevel; } containerList.Add(container); return(containerList); }