예제 #1
0
        public AbstractDomainModel GetAll(SearchCriteriaEnum searchCriteria)
        {
            DomainModel.Models.ProviderRegistration providerRegistration = new DomainModel.Models.ProviderRegistration();

            switch (searchCriteria)
            {
            case CareHub.Core.Enumerations.SearchCriteriaEnum.GET_SPECIALTIES:
                providerRegistration.Specialties = specialtyRepository.GetAll();
                break;

            case CareHub.Core.Enumerations.SearchCriteriaEnum.GET_COUNTRIES:
                providerRegistration.Countries = countryRepository.GetAll();
                break;

            case CareHub.Core.Enumerations.SearchCriteriaEnum.GET_CITIES:
                providerRegistration.Cities = cityRepository.GetAll();
                break;

            case CareHub.Core.Enumerations.SearchCriteriaEnum.GET_LOCALITIES:
                providerRegistration.Localities = localityRepository.GetAll();
                break;

            default:
                break;
            }
            return(providerRegistration);
        }
        public override AbstractDomainModel Query(SearchCriteriaEnum searchCriteria)
        {
            DomainModel.Models.ProviderRegistration providerRegistration = new DomainModel.Models.ProviderRegistration();
            FactoryFacade factory = new FactoryFacade();

            try
            {
                switch (searchCriteria)
                {
                case SearchCriteriaEnum.GET_SPECIALTIES:
                    unitOfWork           = factory.UnitOfWorkFactory.CreateUnitOfWork(typeof(CareHub.UnitOfWork.ProviderRegistrationUOW));
                    providerRegistration = (DomainModel.Models.ProviderRegistration)unitOfWork.GetAll(searchCriteria);
                    break;

                case SearchCriteriaEnum.GET_COUNTRIES:
                    unitOfWork           = factory.UnitOfWorkFactory.CreateUnitOfWork(typeof(CareHub.UnitOfWork.ProviderRegistrationUOW));
                    providerRegistration = (DomainModel.Models.ProviderRegistration)unitOfWork.GetAll(searchCriteria);
                    break;

                case SearchCriteriaEnum.GET_CITIES:
                    unitOfWork           = factory.UnitOfWorkFactory.CreateUnitOfWork(typeof(CareHub.UnitOfWork.ProviderRegistrationUOW));
                    providerRegistration = (DomainModel.Models.ProviderRegistration)unitOfWork.GetAll(searchCriteria);
                    break;

                case SearchCriteriaEnum.GET_LOCALITIES:
                    unitOfWork           = factory.UnitOfWorkFactory.CreateUnitOfWork(typeof(CareHub.UnitOfWork.ProviderRegistrationUOW));
                    providerRegistration = (DomainModel.Models.ProviderRegistration)unitOfWork.GetAll(searchCriteria);
                    break;

                default:
                    break;
                }
            }
            catch (Exception ex)
            {
                switch (searchCriteria)
                {
                case SearchCriteriaEnum.GET_SPECIALTIES:
                    providerRegistration.ResponseMessage = ex.Message;
                    break;

                case SearchCriteriaEnum.GET_COUNTRIES:
                    providerRegistration.ResponseMessage = ex.Message;
                    break;

                case SearchCriteriaEnum.GET_CITIES:
                    providerRegistration.ResponseMessage = ex.Message;
                    break;

                case SearchCriteriaEnum.GET_LOCALITIES:
                    providerRegistration.ResponseMessage = ex.Message;
                    break;

                default:
                    break;
                }
            }
            finally
            {
                factory = null;
            }
            switch (searchCriteria)
            {
            case SearchCriteriaEnum.GET_SPECIALTIES:
                return(providerRegistration);

            case SearchCriteriaEnum.GET_COUNTRIES:
                return(providerRegistration);

            case SearchCriteriaEnum.GET_CITIES:
                return(providerRegistration);

            case SearchCriteriaEnum.GET_LOCALITIES:
                return(providerRegistration);

            default:
                break;
            }
            return(null);
        }
        public override AbstractDomainModel Save(AbstractDomainModel domainModel, CareHub.Factory.Enumerations.DomainModelEnum domainModelType)
        {
            DomainModel.Models.ProviderRegistration providerRegistration = (DomainModel.Models.ProviderRegistration)domainModel;
            try
            {
                if (domainModel != null)
                {
                    switch (domainModelType)
                    {
                    case CareHub.Factory.Enumerations.DomainModelEnum.PROVIDER_REGISTRATION:
                        if (providerRegistration.Name == null || providerRegistration.Name.Length <= 0)
                        {
                            providerRegistration.ResponseMessage = "Name is required.";
                        }
                        else if (providerRegistration.Password == null || providerRegistration.Password.Length <= 0)
                        {
                            providerRegistration.ResponseMessage = "Password is required.";
                        }
                        else if (providerRegistration.ClinicName == null || providerRegistration.ClinicName.Length <= 0)
                        {
                            providerRegistration.ResponseMessage = "Clinic name is required.";
                        }
                        else if (providerRegistration.SpecialtyId <= 0)
                        {
                            providerRegistration.ResponseMessage = "Specialty is required.";
                        }
                        else if (providerRegistration.CityId <= 0)
                        {
                            providerRegistration.ResponseMessage = "City is required.";
                        }
                        else if (providerRegistration.LocalityId <= 0)
                        {
                            providerRegistration.ResponseMessage = "Area is required.";
                        }
                        else
                        {
                            FactoryFacade factory = new FactoryFacade();
                            unitOfWork = factory.UnitOfWorkFactory.CreateUnitOfWork(typeof(CareHub.UnitOfWork.ProviderRegistrationUOW));
                            unitOfWork.Save(providerRegistration);
                            unitOfWork.Commit();
                            providerRegistration.ResponseMessage = "Registration is successful.";

                            CareHub.Core.ConfigurationEmails.ConfigurationEmail.SignupEmail(providerRegistration.Name, providerRegistration.Password, providerRegistration.Email);
                        }
                        break;

                    default:
                        break;
                    }
                }
                else
                {
                    switch (domainModelType)
                    {
                    case CareHub.Factory.Enumerations.DomainModelEnum.PROVIDER_REGISTRATION:
                        providerRegistration.ResponseMessage = "Invalid domain model.";
                        break;

                    default:
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                switch (domainModelType)
                {
                case CareHub.Factory.Enumerations.DomainModelEnum.PROVIDER_REGISTRATION:
                    providerRegistration.ResponseMessage = ex.Message;
                    break;

                default:
                    break;
                }
            }
            switch (domainModelType)
            {
            case CareHub.Factory.Enumerations.DomainModelEnum.PROVIDER_REGISTRATION:
                return(providerRegistration);

            default:
                break;
            }
            return(null);
        }