示例#1
0
        //public static void ConvertToDCOrderEntity(ref DCOrder dcOrder, CreateDCOrderDTO dcOrderDTO, bool isUpdate)
        //{

        //    dcOrder.dco = dcOrderDTO.VLCId;
        //    dcOrder.CustomerId = dcOrderDTO.CustomerId;
        //    dcOrder.OrderComments = dcOrderDTO.ShiftId;


        //}

        public static void ConvertToDCOrderDtlEntity(ref DCOrderDtl dcOrderDtl, CreateDCOrderDtlDTO dCOrderDtlDTO, bool isUpdate)
        {
            if (dCOrderDtlDTO.ActualQuantity > 0)
            {
                dcOrderDtl.ActualQuantity = dCOrderDtlDTO.ActualQuantity;
            }
            else
            {
                dcOrderDtl.ActualQuantity = dCOrderDtlDTO.QuantityOrdered;
            }

            if (dCOrderDtlDTO.QuantityOrdered > 0)
            {
                dcOrderDtl.QuantityOrdered = dCOrderDtlDTO.QuantityOrdered;
            }


            if (dCOrderDtlDTO.ProductId > 0)
            {
                dcOrderDtl.ProductId = dCOrderDtlDTO.ProductId;
            }

            if (dCOrderDtlDTO.UnitPrice > 0)
            {
                dcOrderDtl.UnitPrice = dCOrderDtlDTO.UnitPrice;
            }
            if (dCOrderDtlDTO.TotalPrice > 0)
            {
                dcOrderDtl.OrderTotalPrice = dCOrderDtlDTO.TotalPrice;
            }
        }
 public void Update(DCOrderDtl dCOrderDtl)
 {
     if (dCOrderDtl != null)
     {
         _repository.Entry <Sql.DCOrderDtl>(dCOrderDtl).State = System.Data.Entity.EntityState.Modified;
     }
 }
        //public List<DCOrder> GetAllDCOrderDtlsByDCId(int dCid)
        //{
        //    var dcOrderDtls = _repository.DCOrderDtls.Where(v => v.DCId == dCid).ToList<Sql.DCOrder>();
        //    return dcOrderDtls;
        //}

        public void Add(DCOrderDtl dCOrderDtl)
        {
            if (dCOrderDtl != null)
            {
                _repository.DCOrderDtls.Add(dCOrderDtl);
            }
        }
示例#4
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);
            }
        }
示例#5
0
        public static DCOrderDtlDTO ConvertToDCOrderDtlDto(DCOrderDtl dCOrderDtl, string path)
        {
            DCOrderDtlDTO dCOrderDtlDTO = new DCOrderDtlDTO();

            dCOrderDtlDTO.DCOrderDtlId       = dCOrderDtl.DCOrderDtlId;
            dCOrderDtlDTO.DCOrderId          = dCOrderDtl.DCOrderId;
            dCOrderDtlDTO.ProductId          = dCOrderDtl.ProductId;
            dCOrderDtlDTO.ProductName        = dCOrderDtl.Product.Name;
            dCOrderDtlDTO.ProductDescription = dCOrderDtl.Product.Description;
            dCOrderDtlDTO.ProductImageUrl    = Path.Combine(path, "PROD" + dCOrderDtl.ProductId.ToString() + ".jpg");
            dCOrderDtlDTO.QuantityOrdered    = dCOrderDtl.QuantityOrdered;
            dCOrderDtlDTO.ActualQuantity     = dCOrderDtl.ActualQuantity;
            dCOrderDtlDTO.TotalPrice         = dCOrderDtl.OrderTotalPrice;
            dCOrderDtlDTO.UnitPrice          = dCOrderDtl.UnitPrice.GetValueOrDefault();
            return(dCOrderDtlDTO);
        }