public void GetHospitalPartnerPackageInformation(long medicalVendorId, HospitalPartnerEditModel registrationModel) { var packages = _packageRepository.GetAll(); registrationModel.OrganizationPackageList = packages.Select(x => new OrganizationPackageViewModel { Gender = ((Gender)x.Gender), Id = x.Id, Name = x.Name }) .OrderBy(x => x.Name).ToList(); var defaultPackages = _hospitalPartnerPackageRepository.GetByHospitalpartnerId(medicalVendorId); if (defaultPackages != null) { var activePackageIds = packages.Select(p => p.Id); if (registrationModel.DefaultPackages.IsNullOrEmpty()) { var deactivatedPackageIds = defaultPackages.Where(ap => !activePackageIds.Contains(ap.PackageId)).Select(ap => ap.PackageId); var accountPackages = defaultPackages.Where(ap => !deactivatedPackageIds.Contains(ap.PackageId)); registrationModel.DefaultPackages = _hospitalPartnerPackagFactory.CreateModel(packages, accountPackages); if (!deactivatedPackageIds.IsNullOrEmpty()) { var deactivatedPackages = _packageRepository.GetByIds(deactivatedPackageIds).Select(p => p.Name).ToArray(); registrationModel.DeactivedPackages = string.Format("Package(s) {0} attached with the hospital partner has been deactived. If you save then it will be removed.", string.Join(",", deactivatedPackages)); } } } }
public IEnumerable <EventPackageEditModel> GetEventPackage(long accountId, long hospitalPartnerId, long territoryId, EventType eventType) { IEnumerable <Package> packages = null; IEnumerable <EventPackageEditModel> eventPackages = null; if (accountId > 0) { packages = _packageRepository.GetPackagesByAccount(accountId); if (packages != null && packages.Any()) { eventPackages = Mapper.Map <IEnumerable <Package>, IEnumerable <EventPackageEditModel> >(packages); var accountPackages = _accountPackageRepository.GetByAccountId(accountId); foreach (var eventPackageEditModel in eventPackages) { var accountPackage = accountPackages.Single(ap => ap.PackageId == eventPackageEditModel.PackageId); eventPackageEditModel.IsRecommended = accountPackage.IsRecommended; } return(eventPackages); } } if (hospitalPartnerId > 0) { packages = _packageRepository.GetPackagesByHospitalPartner(hospitalPartnerId); if (packages != null && packages.Any()) { eventPackages = Mapper.Map <IEnumerable <Package>, IEnumerable <EventPackageEditModel> >(packages); var hospitalPartnerPackages = _hospitalPartnerPackageRepository.GetByHospitalpartnerId(hospitalPartnerId); foreach (var eventPackageEditModel in eventPackages) { var hospitalPartnerPackage = hospitalPartnerPackages.Single(ap => ap.PackageId == eventPackageEditModel.PackageId); eventPackageEditModel.IsRecommended = hospitalPartnerPackage.IsRecommended; } return(eventPackages); } } if (territoryId > 0) { packages = _packageRepository.GetPackagesByTerritory(territoryId); if (packages != null && packages.Any()) { eventPackages = Mapper.Map <IEnumerable <Package>, IEnumerable <EventPackageEditModel> >(packages); return(eventPackages); } } packages = _packageRepository.GetPackagesByEventType(eventType); if (packages != null && packages.Any()) { eventPackages = Mapper.Map <IEnumerable <Package>, IEnumerable <EventPackageEditModel> >(packages); return(eventPackages); } return(eventPackages); }