예제 #1
0
        public ResponseDTO AddDCOrder(CreateDCOrderDTO dCOrderDTO)
        {
            ResponseDTO        responseDTO        = new ResponseDTO();
            DistributionCenter distributionCenter = unitOfWork.DistributionCenterRepository.GetById(dCOrderDTO.DCId);

            if (distributionCenter == null)
            {
                throw new PlatformModuleException("DC Details Not Found");
            }
            else if (distributionCenter.DCAddresses != null && distributionCenter.DCAddresses.Count() == 0)
            {
                throw new PlatformModuleException("DC Address details Not Found");
            }
            else
            {
                DCOrder dcOrder = new DCOrder();
                dcOrder.DCOrderId            = unitOfWork.DashboardRepository.NextNumberGenerator("DCOrder");
                dcOrder.DCOrderNumber        = distributionCenter.DCCode + "OD" + dcOrder.DCOrderId.ToString();
                dcOrder.DCId                 = dCOrderDTO.DCId;
                dcOrder.OrderAddressId       = distributionCenter.DCAddresses.FirstOrDefault().DCAddressId;
                dcOrder.OrderDate            = DateTimeHelper.GetISTDateTime();
                dcOrder.CreatedDate          = DateTimeHelper.GetISTDateTime();
                dcOrder.ModifiedDate         = DateTimeHelper.GetISTDateTime();
                dcOrder.CreatedBy            = dcOrder.ModifiedBy = distributionCenter.AgentName;
                dcOrder.IsDeleted            = false;
                dcOrder.OrderStatusId        = (int)OrderStatus.Placed;
                dcOrder.DeliveryExpectedDate = DateTimeHelper.GetISTDateTime().AddDays(1);
                dcOrder.OrderComments        = dCOrderDTO.OrderComments;
                if (dCOrderDTO.CreateDCOrderDtlList != null)
                {
                    foreach (var dcOrderDtlDTO in dCOrderDTO.CreateDCOrderDtlList)
                    {
                        //  this.CheckForExistingCollectionDetailByDateShiftProduct(vLCMilkCollection.CollectionDateTime.Value.Date, vLCMilkCollectionDTO.ShiftId, vlcCollectionDtlDTO.ProductId, vLCMilkCollectionDTO.CustomerId);
                        DCOrderDtl dCOrderDtl = new DCOrderDtl();
                        dCOrderDtl.DCOrderDtlId = unitOfWork.DashboardRepository.NextNumberGenerator("DCOrderDtl");
                        dCOrderDtl.DCOrderId    = dcOrder.DCOrderId;
                        DCOrderConvertor.ConvertToDCOrderDtlEntity(ref dCOrderDtl, dcOrderDtlDTO, false);
                        unitOfWork.DCOrderDtlRepository.Add(dCOrderDtl);
                    }

                    dcOrder.OrderTotalPrice     = dCOrderDTO.CreateDCOrderDtlList.Sum(s => s.TotalPrice);
                    dcOrder.TotalOrderQuantity  = dCOrderDTO.CreateDCOrderDtlList.Sum(s => s.QuantityOrdered);
                    dcOrder.TotalActualQuantity = dcOrder.TotalOrderQuantity;
                }
                else
                {
                    throw new PlatformModuleException("DC Order Detail Not Found");
                }

                unitOfWork.DCOrderRepository.Add(dcOrder);
                //   UpdateOrderPaymentDetailsForOrder(distributionCenter, dcOrder);
                unitOfWork.SaveChanges();
                responseDTO.Status  = true;
                responseDTO.Message = String.Format("DC Order Placed Successfully ");
                responseDTO.Data    = this.GetOrderDetailsByOrderId(dcOrder.DCOrderId);

                return(responseDTO);
            }
        }
예제 #2
0
        public ResponseDTO GetOrderDetailsByOrderId(int orderId)
        {
            ResponseDTO responseDTO = new ResponseDTO();

            responseDTO.Status  = true;
            responseDTO.Message = String.Format("DC Order Details");
            var dcOrder = unitOfWork.DCOrderRepository.GetDCOrderByOrderId(orderId);

            DCOrderDTO dCOrderDTO = DCOrderConvertor.ConvertToDCOrderDto(dcOrder, NatrajConfigurationHelper.ImagePath);

            responseDTO.Data = dCOrderDTO;
            return(responseDTO);
        }
예제 #3
0
        public ResponseDTO GetAllDCOrders()
        {
            ResponseDTO responseDTO = new ResponseDTO();

            responseDTO.Status  = true;
            responseDTO.Message = String.Format("DC Order Details");
            var dcOrders = unitOfWork.DCOrderRepository.GetAll();

            List <DCOrderDTO> dcOrderDTOList = new List <DCOrderDTO>();

            foreach (var dcOrder in dcOrders)
            {
                dcOrderDTOList.Add(DCOrderConvertor.ConvertToDCOrderDto(dcOrder, NatrajConfigurationHelper.ImagePath));
            }
            responseDTO.Data = dcOrderDTOList;
            return(responseDTO);
        }
예제 #4
0
        public ResponseDTO UpdateDCOrder(CreateDCOrderDTO dCOrderDTO)
        {
            ResponseDTO        responseDTO        = new ResponseDTO();
            DistributionCenter distributionCenter = unitOfWork.DistributionCenterRepository.GetById(dCOrderDTO.DCId);
            var dcOrder = unitOfWork.DCOrderRepository.GetDCOrderByOrderId(dCOrderDTO.DCOrderId);

            if (dcOrder != null && dCOrderDTO != null && dCOrderDTO.CreateDCOrderDtlList != null)
            {
                dcOrder.ModifiedDate         = DateTimeHelper.GetISTDateTime();
                dcOrder.ModifiedBy           = distributionCenter.AgentName;
                dcOrder.OrderStatusId        = (int)OrderStatus.Received;
                dcOrder.DeliveryExpectedDate = DateTimeHelper.GetISTDateTime();
                dcOrder.DeliveredDate        = DateTimeHelper.GetISTDateTime();
                if (string.IsNullOrWhiteSpace(dCOrderDTO.OrderComments) == false)
                {
                    dcOrder.OrderComments = dCOrderDTO.OrderComments;
                }
                if (dCOrderDTO.CreateDCOrderDtlList != null)
                {
                    foreach (var dcOrderDtlDTO in dCOrderDTO.CreateDCOrderDtlList)
                    {
                        //  this.CheckForExistingCollectionDetailByDateShiftProduct(vLCMilkCollection.CollectionDateTime.Value.Date, vLCMilkCollectionDTO.ShiftId, vlcCollectionDtlDTO.ProductId, vLCMilkCollectionDTO.CustomerId);
                        var dcOrderDtl = unitOfWork.DCOrderDtlRepository.GetById(dcOrderDtlDTO.DCOrderDtlId);

                        DCOrderConvertor.ConvertToDCOrderDtlEntity(ref dcOrderDtl, dcOrderDtlDTO, false);
                        unitOfWork.DCOrderDtlRepository.Update(dcOrderDtl);
                    }

                    dcOrder.OrderTotalPrice     = dCOrderDTO.CreateDCOrderDtlList.Sum(s => s.TotalPrice);
                    dcOrder.TotalActualQuantity = dCOrderDTO.CreateDCOrderDtlList.Sum(s => s.ActualQuantity);
                }
            }
            else
            {
                throw new PlatformModuleException("DC Order Detail Not Found");
            }
            unitOfWork.DCOrderRepository.Update(dcOrder);
            UpdateOrderPaymentDetailsForOrder(distributionCenter, dcOrder);
            unitOfWork.SaveChanges();
            responseDTO.Status  = true;
            responseDTO.Message = String.Format("DC Order Placed Successfully ");
            responseDTO.Data    = this.GetOrderDetailsByOrderId(dcOrder.DCOrderId);

            return(responseDTO);
        }