public ResponseDTO AddDistributionCenter(DistributionCenterDTO distributionCenterDTO) { this.CheckForExisitngDistributionCenter(distributionCenterDTO); ResponseDTO responseDTO = new ResponseDTO(); DistributionCenter distributionCenter = new DistributionCenter(); distributionCenter.DCId = unitOfWork.DashboardRepository.NextNumberGenerator("DistributionCenter"); distributionCenterDTO.Password = EncryptionHelper.Encryptword(distributionCenterDTO.Password); DistributionCenterConvertor.ConvertToDistributionCenterEntity(ref distributionCenter, distributionCenterDTO, false); // customer.CustomerCode = unitOfWork.CustomerRepository.GetCustomerCodeIdByVLC(customerDto.VLCId); distributionCenter.DCCode = "DC" + distributionCenter.DCId.ToString(); distributionCenter.CreatedDate = DateTimeHelper.GetISTDateTime(); distributionCenter.ModifiedDate = DateTimeHelper.GetISTDateTime(); distributionCenter.CreatedBy = distributionCenter.ModifiedBy = "Admin"; // unitOfWork.VLCRepository.GetEmployeeNameByVLCId(customerDto.VLCId); distributionCenter.DateOfRegistration = DateTimeHelper.GetISTDateTime().Date; distributionCenter.IsDeleted = false; distributionCenter.Pin = OTPGenerator.GetSixDigitOTP(); distributionCenterDTO.DCId = distributionCenter.DCId; //creating Distribution Center wallet with Distribution Center AddDistributionCenterWallet(distributionCenter); DCAddress dCAddress = AddDistributionCenterAddress(distributionCenterDTO); if (dCAddress != null) { distributionCenter.DCAddresses.Add(dCAddress); } unitOfWork.DistributionCenterRepository.Add(distributionCenter); unitOfWork.SaveChanges(); responseDTO.Status = true; responseDTO.Message = String.Format("Distribution Center Successfully Created"); responseDTO.Data = DistributionCenterConvertor.ConvertToDistributionCenterDto(distributionCenter); return(responseDTO); }
public ResponseDTO GetDistributionCenterByCenterId(int dcId) { ResponseDTO responseDTO = new ResponseDTO(); DistributionCenterDTO distributionCenterDTO = null; var distributionCenter = unitOfWork.DistributionCenterRepository.GetById(dcId); if (distributionCenter != null) { distributionCenterDTO = DistributionCenterConvertor.ConvertToDistributionCenterDto(distributionCenter); responseDTO.Status = true; responseDTO.Message = "Distribution Center Details By DC Id"; responseDTO.Data = distributionCenterDTO; } else { throw new PlatformModuleException("Distribution Center Details Not Found"); } return(responseDTO); }
public ResponseDTO UpdateDistributionCenterStatus(int dcId, bool status) { ResponseDTO responseDTO = new ResponseDTO(); responseDTO.Message = "Distribution Center Details by city"; responseDTO.Status = true; var dc = unitOfWork.DistributionCenterRepository.GetById(dcId); if (dc != null) { dc.IsDeleted = !status; unitOfWork.SaveChanges(); responseDTO.Data = DistributionCenterConvertor.ConvertToDistributionCenterDto(dc); return(responseDTO); } else { throw new PlatformModuleException("Distribution Center Details Not Found"); } }
public ResponseDTO GetDistributionCentersByCity(string city, int?pageNumber) { ResponseDTO responseDTO = new ResponseDTO(); responseDTO.Message = "Distribution Center Details by city"; responseDTO.Status = true; List <DistributionCenterDTO> dcList = new List <DistributionCenterDTO>(); var distributionCenters = unitOfWork.DistributionCenterRepository.GetDistributionCenterListByCity(city, pageNumber); if (distributionCenters != null) { foreach (var dc in distributionCenters) { dcList.Add(DistributionCenterConvertor.ConvertToDistributionCenterDto(dc)); } } responseDTO.Data = dcList; return(responseDTO); }
public ResponseDTO GetAllDistributionCenters() { ResponseDTO responseDTO = new ResponseDTO(); responseDTO.Message = "Distribution Center Details"; responseDTO.Status = true; List <DistributionCenterDTO> dcList = new List <DistributionCenterDTO>(); var distributionCenters = unitOfWork.DistributionCenterRepository.GetAll(); if (distributionCenters != null) { foreach (var dc in distributionCenters) { dcList.Add(DistributionCenterConvertor.ConvertToDistributionCenterDto(dc)); } } responseDTO.Data = dcList; return(responseDTO); }
public ResponseDTO UpdateDistributionCenter(DistributionCenterDTO distributionCenterDTO) { var distributionCenter = unitOfWork.DistributionCenterRepository.GetById(distributionCenterDTO.DCId); if (distributionCenter != null) { DistributionCenterConvertor.ConvertToDistributionCenterEntity(ref distributionCenter, distributionCenterDTO, true); distributionCenter.ModifiedBy = distributionCenter.AgentName; distributionCenter.ModifiedDate = DateTimeHelper.GetISTDateTime(); unitOfWork.DistributionCenterRepository.Update(distributionCenter); unitOfWork.SaveChanges(); ResponseDTO responseDTO = new ResponseDTO(); responseDTO.Status = true; responseDTO.Message = "Distribution Center Succesfully Updated"; responseDTO.Data = DistributionCenterConvertor.ConvertToDistributionCenterDto(distributionCenter); return(responseDTO); } else { throw new PlatformModuleException("Distribution Center Not Found with given DC Id"); } }