Exemplo n.º 1
0
        public override AbstractDomainModel Query(SearchCriteriaEnum searchCriteria)
        {
            signup = new DomainModel.Models.Signup();
            FactoryFacade factory = new FactoryFacade();

            try
            {
                switch (searchCriteria)
                {
                case SearchCriteriaEnum.GET_ALL_SECURITY_QUESTIONS:
                    unitOfWork = factory.UnitOfWorkFactory.CreateUnitOfWork(typeof(JunkCar.UnitOfWork.UOWs.AccountsUOW));
                    signup     = (DomainModel.Models.Signup)unitOfWork.GetAll(searchCriteria);
                    break;

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

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

            default:
                break;
            }
            return(null);
        }
Exemplo n.º 2
0
        public override AbstractDomainModel Save(AbstractDomainModel domainModel, DomainModelEnum domainModelType)
        {
            signup = (JunkCar.DomainModel.Models.Signup)domainModel;
            try
            {
                if (domainModel != null)
                {
                    switch (domainModelType)
                    {
                    case DomainModelEnum.SIGNUP:
                        if (signup.Name == null || signup.Name.Length <= 0)
                        {
                            signup.ResponseMessage = "Name is required.";
                        }
                        else if (signup.Password == null || signup.Password.Length <= 0)
                        {
                            signup.ResponseMessage = "Password is required.";
                        }
                        else if (signup.ZipCode == null || signup.ZipCode.Length <= 0)
                        {
                            signup.ResponseMessage = "Zip code is required.";
                        }
                        else
                        {
                            FactoryFacade factory = new FactoryFacade();
                            unitOfWork = factory.UnitOfWorkFactory.CreateUnitOfWork(typeof(JunkCar.UnitOfWork.UOWs.AccountsUOW));
                            unitOfWork.Save(signup);
                            unitOfWork.Commit();
                            signup.ResponseMessage = "Your account has been created successfully and you will receive an email shortly with the details";

                            JunkCar.Core.ConfigurationEmails.ConfigurationEmail.SignupEmail(signup.Email, signup.Name, signup.Password, signup.Email);
                        }
                        break;

                    default:
                        break;
                    }
                }
                else
                {
                    switch (domainModelType)
                    {
                    case DomainModelEnum.SIGNUP:
                        signup.ResponseMessage = "Invalid domain model.";
                        break;

                    default:
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                switch (domainModelType)
                {
                case DomainModelEnum.SIGNUP:
                    signup.ResponseMessage = ex.Message;
                    break;

                default:
                    break;
                }
            }
            switch (domainModelType)
            {
            case DomainModelEnum.SIGNUP:
                return(signup);

            default:
                break;
            }
            return(null);
        }