public async Task <ConfirmArrivalDtos> CreateOrUpdateCAAsync(int containerId, DateTime arrivalDate)
        {
            CA entity = await GetCAbyContainerId(containerId);

            ConfirmArrivalDtos input = new ConfirmArrivalDtos();

            input.ContainerId = containerId;
            input.ArrivalDate = arrivalDate;

            if (entity != null)
            {
                entity.ArrivalDate = input.ArrivalDate;

                _confirmArrivalRepository.Update(entity);
            }
            else
            {
                entity = Mapper.Map <CA>(input);

                _confirmArrivalRepository.Insert(entity);
            }

            await UpdateContainer(containerId, arrivalDate);

            await UnitOfWork.SaveChangesAsync();

            return(Mapper.Map <ConfirmArrivalDtos>(entity));
        }
예제 #2
0
        public async Task <ActionResult> Search(ConfirmArrivalDtos model, string page = null)
        {
            SetDropDownList();
            if (page == null)
            {
                page = "1";
            }
            int pageIndex = int.Parse(page);

            ViewBag.Page = pageIndex;

            model.Containers = new PagedListResult <ConfirmArrivalResultDtos>();

            model.Containers = await _CAService.ListContainerFilterAsync(pageIndex, model.FilterDtos.ETAFrom, model.FilterDtos.ETATo, model.FilterDtos.Origin,
                                                                         model.FilterDtos.Mode, model.FilterDtos.Vendor, model.FilterDtos.Container, model.FilterDtos.Status);

            PagedListResult <ConfirmArrivalResultDtos> nextPage     = new PagedListResult <ConfirmArrivalResultDtos>();
            PagedListResult <ConfirmArrivalResultDtos> previousPage = new PagedListResult <ConfirmArrivalResultDtos>();

            previousPage.Items = new List <ConfirmArrivalResultDtos>();

            if (pageIndex - 1 > 0)
            {
                previousPage = await _CAService.ListContainerFilterAsync(pageIndex - 1, model.FilterDtos.ETAFrom, model.FilterDtos.ETATo, model.FilterDtos.Origin,
                                                                         model.FilterDtos.Mode, model.FilterDtos.Vendor, model.FilterDtos.Container, model.FilterDtos.Status);
            }
            nextPage = await _CAService.ListContainerFilterAsync(pageIndex + 1, model.FilterDtos.ETAFrom, model.FilterDtos.ETATo, model.FilterDtos.Origin,
                                                                 model.FilterDtos.Mode, model.FilterDtos.Vendor, model.FilterDtos.Container, model.FilterDtos.Status);

            if ((model.Containers.Items.Count > 0) && (nextPage.Items.Count > 0))
            {
                if (SameGroup(model.Containers.Items[model.Containers.Items.Count - 1], nextPage.Items[0]))
                {
                    ViewBag.ToBeContinued = true;
                }
            }

            if ((model.Containers.Items.Count > 0) && (previousPage.Items.Count > 0))
            {
                if (SameGroup(model.Containers.Items[0], previousPage.Items[previousPage.Items.Count - 1]))
                {
                    ViewBag.ContinuedFromPrevious = true;
                }
            }

            return(PartialView("_Result", model));
        }
예제 #3
0
        public async Task <ActionResult> Achieve(ConfirmArrivalDtos model)
        {
            SetDropDownList();

            if (ModelState.IsValid)
            {
                if (model.Containers != null)
                {
                    if (SelectAtLeastOne(model.Containers.Items))
                    {
                        {
                            foreach (var item in model.Containers.Items)
                            {
                                if (item.Selected)
                                {
                                    await _CAService.CreateOrUpdateCAAsync(item.Id, model.ListArrivalDate[item.GroupId]);

                                    item.ArrivalDate = model.ListArrivalDate[item.GroupId];
                                    item.Status      = ContainerStatus.Arrived;
                                }
                            }

                            model.Containers.Items = model.Containers.Items.OrderBy(p => p.DestinationPort).ThenBy(p => p.Origin).ThenBy(p => p.Mode).ThenBy(p => p.Carrier).ThenBy(p => p.ArrivalDate).ThenBy(p => p.Container).ToList();
                            ModelState.Clear();
                            ViewBag.ShowModal = "Updated";
                        }
                    }
                    else
                    {
                        ViewBag.ShowModal = "NoItem";
                    }
                }
            }

            return(PartialView("_Result", model));
        }
예제 #4
0
        public async Task <ActionResult> Index()
        {
            SetDropDownList();
            ConfirmArrivalDtos model = new ConfirmArrivalDtos();

            model.FilterDtos = new ConfirmArrivalFilterDtos();
            model.Containers = new PagedListResult <ConfirmArrivalResultDtos>();

            model.Containers = await _CAService.ListContainerFilterAsync(null, null, null, null, null, null, null, null);

            PagedListResult <ConfirmArrivalResultDtos> nextPage = new PagedListResult <ConfirmArrivalResultDtos>();

            nextPage = await _CAService.ListContainerFilterAsync(2, null, null, null, null, null, null, null);

            if ((model.Containers.Items.Count > 0) && (nextPage.Items.Count > 0))
            {
                if (SameGroup(model.Containers.Items[model.Containers.Items.Count - 1], nextPage.Items[0]))
                {
                    ViewBag.ToBeContinued = true;
                }
            }

            return(View(model));
        }