public async Task <ActionResult> Search(VesselDepartureDtos model, string page = null) { SetDropDownList(); if (page == null) { page = "1"; } int pageIndex = int.Parse(page); ViewBag.Page = pageIndex; model.ResultDtos = new PagedListResult <ContainerDto>(); model.ResultDtos = await _vesselDepartureService.ListContainerDtoAsync(pageIndex, model.FilterDto.Origin, model.FilterDto.OriginPort, model.FilterDto.Container, model.FilterDto.Status, model.FilterDto.ETDFrom, model.FilterDto.ETDTo); PagedListResult <ContainerDto> nextPage = new PagedListResult <ContainerDto>(); PagedListResult <ContainerDto> previousPage = new PagedListResult <ContainerDto>(); previousPage.Items = new List <ContainerDto>(); if (pageIndex - 1 > 0) { previousPage = await _vesselDepartureService.ListContainerDtoAsync(pageIndex - 1, model.FilterDto.Origin, model.FilterDto.OriginPort, model.FilterDto.Container, model.FilterDto.Status, model.FilterDto.ETDFrom, model.FilterDto.ETDTo); } nextPage = await _vesselDepartureService.ListContainerDtoAsync(pageIndex + 1, model.FilterDto.Origin, model.FilterDto.OriginPort, model.FilterDto.Container, model.FilterDto.Status, model.FilterDto.ETDFrom, model.FilterDto.ETDTo); if ((model.ResultDtos.Items.Count > 0) && (nextPage.Items.Count > 0)) { if (SameGroup(model.ResultDtos.Items[model.ResultDtos.Items.Count - 1], nextPage.Items[0])) { ViewBag.ToBeContinued = true; } } if ((model.ResultDtos.Items.Count > 0) && (previousPage.Items.Count > 0)) { if (SameGroup(model.ResultDtos.Items[0], previousPage.Items[previousPage.Items.Count - 1])) { ViewBag.ContinuedFromPrevious = true; } } return(PartialView("_Result", model)); }
public async Task <ActionResult> Achieve(VesselDepartureDtos model) { SetDropDownList(); if (ModelState.IsValid) { if (model.ResultDtos != null) { if (SelectAtLeastOne(model.ResultDtos.Items)) { { foreach (var item in model.ResultDtos.Items) { if (item.Selected) { await _vesselDepartureService.CreateOrUpdateAsync(item, model.ContainerInfoDtos[item.GroupId]); item.OriginPort = model.ContainerInfoDtos[item.GroupId].OriginPort; item.DestinationPort = model.ContainerInfoDtos[item.GroupId].DestinationPort; item.Mode = model.ContainerInfoDtos[item.GroupId].Mode; item.Carrier = model.ContainerInfoDtos[item.GroupId].Carrier; item.Status = ContainerStatus.Despatch; } } model.ResultDtos.Items = model.ResultDtos.Items.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(); ModelState.Clear(); ViewBag.ShowModal = "Updated"; } } else { ViewBag.ShowModal = "NoItem"; } } } return(PartialView("_Result", model)); }
public async Task <ActionResult> Index() { SetDropDownList(); VesselDepartureDtos model = new VesselDepartureDtos(); model.FilterDto = new FilterDto(); model.ResultDtos = new PagedListResult <ContainerDto>(); model.ResultDtos = await _vesselDepartureService.ListContainerDtoAsync(null, null, null, null, null, null, null); PagedListResult <ContainerDto> nextPage = new PagedListResult <ContainerDto>(); nextPage = await _vesselDepartureService.ListContainerDtoAsync(2, null, null, null, null, null, null); if ((model.ResultDtos.Items.Count > 0) && (nextPage.Items.Count > 0)) { if (SameGroup(model.ResultDtos.Items[model.ResultDtos.Items.Count - 1], nextPage.Items[0])) { ViewBag.ToBeContinued = true; } } return(View("Index", model)); }