Esempio n. 1
0
        public static DCOrderDTO ConvertToDCOrderDto(DCOrder dCOrder, string path)
        {
            DCOrderDTO dCOrderDTO = new DCOrderDTO();

            dCOrderDTO.DCId                 = dCOrder.DCId;
            dCOrderDTO.DCOrderId            = dCOrder.DCOrderId;
            dCOrderDTO.DCOrderNumber        = dCOrder.DCOrderNumber;
            dCOrderDTO.DeliveryExpectedDate = dCOrder.DeliveryExpectedDate.HasValue ? dCOrder.DeliveryExpectedDate : DateTime.Now.Date;
            dCOrderDTO.DeliveredDate        = dCOrder.DeliveredDate.HasValue ? dCOrder.DeliveredDate : DateTime.Now.Date;
            dCOrderDTO.DeliveredBy          = dCOrder.DeliveredBy;
            dCOrderDTO.OrderComments        = dCOrder.OrderComments;
            dCOrderDTO.OrderDate            = dCOrder.OrderDate;
            dCOrderDTO.OrderTotalPrice      = dCOrder.OrderTotalPrice;
            dCOrderDTO.TotalOrderQuantity   = dCOrder.TotalOrderQuantity;
            dCOrderDTO.TotalActualQuantity  = dCOrder.TotalActualQuantity.GetValueOrDefault();
            OrderStatus status;

            Enum.TryParse <OrderStatus>(dCOrder.OrderStatusId.ToString(), out status);
            dCOrderDTO.OrderStatus = status;
            dCOrderDTO.DCName      = dCOrder.DistributionCenter != null ? dCOrder.DistributionCenter.DCName : string.Empty;
            if (dCOrder.DCAddress != null)
            {
                dCOrderDTO.dCAddressDTO = DCAddressConvertor.ConvertToDCAddressDTO(dCOrder.DCAddress);
            }
            if (dCOrder.DCOrderDtls != null)
            {
                dCOrderDTO.dcOrderDtlList = new List <DCOrderDtlDTO>();
                foreach (var dcorderDtl in dCOrder.DCOrderDtls)
                {
                    dCOrderDTO.dcOrderDtlList.Add(ConvertToDCOrderDtlDto(dcorderDtl, path));
                }
            }
            return(dCOrderDTO);
        }
Esempio n. 2
0
        public ResponseDTO AddDCAddress(DCAddressDTO dCAddressDto)
        {
            ResponseDTO responseDTO        = new ResponseDTO();
            DCAddress   dCAddress          = new DCAddress();
            var         exisitingdCAddress = unitOfWork.DCAddressRepository.GetDefaultAddressByDCId(dCAddressDto.DCId);

            if (exisitingdCAddress != null)
            {
                responseDTO.Status  = true;
                responseDTO.Message = "One DC Address already exist. You can only add one address.";
            }
            else
            {
                //throw new PlatformModuleException(string.Format("DC Address Details Already Exist For DC Id {0}", dCAddressDto.DCId));

                dCAddress.DCAddressId = unitOfWork.DashboardRepository.NextNumberGenerator("DCAddress");
                DCAddressConvertor.ConvertToDCAddressEntity(ref dCAddress, dCAddressDto, false);
                dCAddress.IsDefaultAddress = true;
                dCAddress.IsDeleted        = false;

                unitOfWork.DCAddressRepository.Add(dCAddress);
                unitOfWork.SaveChanges();
                dCAddressDto        = DCAddressConvertor.ConvertToDCAddressDTO(dCAddress);
                responseDTO.Status  = true;
                responseDTO.Message = "DC Address Added Successfully";
                responseDTO.Data    = dCAddressDto;
            }
            return(responseDTO);
        }
Esempio n. 3
0
        public static DistributionCenterDTO ConvertToDistributionCenterDto(DistributionCenter distributionCenter)
        {
            DistributionCenterDTO distributionCenterDTO = new DistributionCenterDTO();

            distributionCenterDTO.AADHAR             = distributionCenter.AADHAR;
            distributionCenterDTO.AgentName          = distributionCenter.AgentName;
            distributionCenterDTO.AlternateContact   = distributionCenter.AlternateContact;
            distributionCenterDTO.Anniversary        = distributionCenter.Anniversary.HasValue ? distributionCenter.Anniversary.Value : DateTime.MinValue;
            distributionCenterDTO.Contact            = distributionCenter.Contact;
            distributionCenterDTO.CreatedBy          = distributionCenter.CreatedBy;
            distributionCenterDTO.CreatedDate        = distributionCenter.CreatedDate;
            distributionCenterDTO.DateOfRegistration = distributionCenter.DateOfRegistration.HasValue ? distributionCenter.DateOfRegistration.Value : DateTime.MinValue;
            distributionCenterDTO.DCCode             = distributionCenter.DCCode;
            distributionCenterDTO.DCId         = distributionCenter.DCId;
            distributionCenterDTO.DCName       = distributionCenter.DCName;
            distributionCenterDTO.DOB          = distributionCenter.DOB.HasValue ? distributionCenter.DOB.Value : DateTime.MinValue;
            distributionCenterDTO.Email        = distributionCenter.Email;
            distributionCenterDTO.FatherName   = distributionCenter.FatherName;
            distributionCenterDTO.ModifiedBy   = distributionCenter.ModifiedBy;
            distributionCenterDTO.ModifiedDate = distributionCenter.ModifiedDate.HasValue ? distributionCenter.ModifiedDate.Value : DateTime.MinValue;
            distributionCenterDTO.NoOfEmployee = distributionCenter.NoOfEmployee.GetValueOrDefault();
            distributionCenterDTO.IsActive     = distributionCenter.IsDeleted.GetValueOrDefault();
            if (distributionCenter.DCWallets != null)
            {
                distributionCenterDTO.DcWalletBalance = distributionCenter.DCWallets.FirstOrDefault().WalletBalance;
            }
            if (distributionCenter.DCAddresses != null && distributionCenter.DCAddresses.Count() > 0)
            {
                distributionCenterDTO.DCAddressDTO = DCAddressConvertor.ConvertToDCAddressDTO(distributionCenter.DCAddresses.FirstOrDefault());
            }

            return(distributionCenterDTO);
        }
Esempio n. 4
0
        public ResponseDTO GetDCAddressById(int Id)
        {
            var          dCAddress    = unitOfWork.DCAddressRepository.GetById(Id);
            DCAddressDTO dCAddressDto = DCAddressConvertor.ConvertToDCAddressDTO(dCAddress);
            ResponseDTO  response     = new ResponseDTO();

            response.Data    = dCAddressDto;
            response.Status  = true;
            response.Message = "DC address found.";

            return(response);
        }
Esempio n. 5
0
        public List <DCAddressDTO> GetAllDCAddresses()
        {
            List <DCAddressDTO> dCAddressList = new List <DCAddressDTO>();
            var dCAddresses = unitOfWork.DCAddressRepository.GetAll();

            if (dCAddresses != null)
            {
                foreach (var dCAddress in dCAddresses)
                {
                    dCAddressList.Add(DCAddressConvertor.ConvertToDCAddressDTO(dCAddress));
                }
            }

            return(dCAddressList);
        }
Esempio n. 6
0
        public ResponseDTO DeleteDCAddress(int id)
        {
            ResponseDTO responseDTO = new ResponseDTO();
            UnitOfWork  unitOfWork  = new UnitOfWork();
            //get dCAddress
            var dCAddress = unitOfWork.DCAddressRepository.GetById(id);

            dCAddress.IsDeleted = true;
            unitOfWork.DCAddressRepository.Update(dCAddress);
            unitOfWork.SaveChanges();
            DCAddressDTO dCAddressDTO = DCAddressConvertor.ConvertToDCAddressDTO(dCAddress);

            responseDTO.Status  = true;
            responseDTO.Message = "DC Address Deleted Successfully";
            responseDTO.Data    = dCAddressDTO;
            return(responseDTO);
        }
        public DCAddress AddDistributionCenterAddress(DistributionCenterDTO distributionCenterDTO)
        {
            if (distributionCenterDTO.DCAddressDTO != null)
            {
                distributionCenterDTO.DCAddressDTO.DCId    = distributionCenterDTO.DCId;
                distributionCenterDTO.DCAddressDTO.Contact = distributionCenterDTO.Contact;
                DCAddress dCAddress = new DCAddress();
                dCAddress.DCAddressId = unitOfWork.DashboardRepository.NextNumberGenerator("DCAddress");

                dCAddress.AddressTypeId    = 1;
                dCAddress.IsDefaultAddress = true;
                DCAddressConvertor.ConvertToDCAddressEntity(ref dCAddress, distributionCenterDTO.DCAddressDTO, false);
                //   unitOfWork.DCAddressRepository.Add(dCAddress);
                return(dCAddress);
            }
            else
            {
                throw new PlatformModuleException("Distribution Center Address Details Not Provided");
            }
        }
Esempio n. 8
0
        public ResponseDTO GetDefaultDCAddressByDCId(int dcId)
        {
            ResponseDTO  responseDTO  = new ResponseDTO();
            DCAddressDTO dCAddressDto = null;
            var          dCAddress    = unitOfWork.DCAddressRepository.GetDefaultAddressByDCId(dcId);

            if (dCAddress != null)
            {
                dCAddressDto        = DCAddressConvertor.ConvertToDCAddressDTO(dCAddress);
                responseDTO.Status  = true;
                responseDTO.Message = "DC Address Details For Distribution Center";
                responseDTO.Data    = dCAddressDto;
            }
            else
            {
                responseDTO.Status  = false;
                responseDTO.Message = String.Format("DC Address Details with DC ID {0} not found", dcId);
                responseDTO.Data    = new object();
            }
            return(responseDTO);
        }
Esempio n. 9
0
        public ResponseDTO UpdateDCAddress(DCAddressDTO dCAddressDto)
        {
            ResponseDTO responseDTO = new ResponseDTO();
            var         dCAddress   = unitOfWork.DCAddressRepository.GetDefaultAddressByDCId(dCAddressDto.DCId);

            if (dCAddress == null)
            {
                return(AddDCAddress(dCAddressDto));
            }

            DCAddressConvertor.ConvertToDCAddressEntity(ref dCAddress, dCAddressDto, true);

            //    dCAddress.ModifiedBy = unitOfWork.VLCRepository.GetEmployeeNameByVLCId(dCAddress.Customer.VLCId.GetValueOrDefault());

            unitOfWork.DCAddressRepository.Update(dCAddress);
            unitOfWork.SaveChanges();
            dCAddressDto        = DCAddressConvertor.ConvertToDCAddressDTO(dCAddress);
            responseDTO.Status  = true;
            responseDTO.Message = "DC Address Updated Successfully";
            responseDTO.Data    = dCAddressDto;
            return(responseDTO);
        }
Esempio n. 10
0
        public ResponseDTO GetAllDCAddressByDCId(int dcId)
        {
            ResponseDTO         responseDTO  = new ResponseDTO();
            List <DCAddressDTO> dCAddresses  = new List <DCAddressDTO>();
            List <DCAddress>    dCAddressAll = unitOfWork.DCAddressRepository.GetAllDCAddressByDCId(dcId);

            if (dCAddressAll != null)
            {
                foreach (var address in dCAddressAll)
                {
                    dCAddresses.Add(DCAddressConvertor.ConvertToDCAddressDTO(address));
                }
                responseDTO.Status  = true;
                responseDTO.Message = "DC Address Details For Distribution Center";
                responseDTO.Data    = dCAddresses;
            }
            else
            {
                responseDTO.Status  = false;
                responseDTO.Message = String.Format("DC Address Details with DC ID {0} not found", dcId);
                responseDTO.Data    = new object();
            }
            return(responseDTO);
        }