public override AbstractDomainModel Query(AbstractDomainModel domainModel, DomainModelEnum domainModelType) { try { if (domainModel != null) { FactoryFacade factory = new FactoryFacade(); switch (domainModelType) { case DomainModelEnum.GET_MAKES: home = (DomainModel.Models.Home)domainModel; if (home.SelectedYear <= 0) { home.ResponseMessage = "Must select a year"; } else { unitOfWork = factory.UnitOfWorkFactory.CreateUnitOfWork(typeof(JunkCar.UnitOfWork.UOWs.HomeUOW)); home = (DomainModel.Models.Home)unitOfWork.Get(home,OperationTypeEnum.GET_MAKES); home.ResponseMessage = "Valid"; } break; case DomainModelEnum.GET_MODELS: home = (DomainModel.Models.Home)domainModel; if (home.SelectedYear <= 0) { home.ResponseMessage = "Must select a year"; } else if (home.SelectedMakeId <= 0) { home.ResponseMessage = "Must select a model"; } else { unitOfWork = factory.UnitOfWorkFactory.CreateUnitOfWork(typeof(JunkCar.UnitOfWork.UOWs.HomeUOW)); home = (DomainModel.Models.Home)unitOfWork.Get(home,OperationTypeEnum.GET_MODLES); home.ResponseMessage = "Valid"; } break; case DomainModelEnum.CHECK_ZIPCODE: home = (DomainModel.Models.Home)domainModel; if (home.ZipCode == null || home.ZipCode == "" || home.ZipCode == string.Empty ) { home.ResponseMessage = "Must enter a zipcode"; } else { unitOfWork = factory.UnitOfWorkFactory.CreateUnitOfWork(typeof(JunkCar.UnitOfWork.UOWs.HomeUOW)); home = (DomainModel.Models.Home)unitOfWork.Get(home,OperationTypeEnum.CHECK_ZIPCODE); home.ResponseMessage = "Valid"; } break; case DomainModelEnum.GET_CITIES: home = (DomainModel.Models.Home)domainModel; if (home.StateId <= 0) { home.ResponseMessage = "Must select a state"; } else { unitOfWork = factory.UnitOfWorkFactory.CreateUnitOfWork(typeof(JunkCar.UnitOfWork.UOWs.HomeUOW)); home = (DomainModel.Models.Home)unitOfWork.Get(home,OperationTypeEnum.GET_CITIES); home.ResponseMessage = "Valid"; } break; case DomainModelEnum.GET_AN_OFFER: home = (DomainModel.Models.Home)domainModel; //else //{ unitOfWork = factory.UnitOfWorkFactory.CreateUnitOfWork(typeof(JunkCar.UnitOfWork.UOWs.HomeUOW)); home = (DomainModel.Models.Home)unitOfWork.Get(home,OperationTypeEnum.GET_AN_OFFER); home.ResponseMessage = "Valid"; //} break; case DomainModelEnum.GET_A_BETTER_OFFER: home = (DomainModel.Models.Home)domainModel; if (home.SelectedYear <= 0) { home.ResponseMessage = "Must select a year"; } else if (home.SelectedMakeId <= 0) { home.ResponseMessage = "Must select a make"; } else if (home.SelectedModelId <= 0) { home.ResponseMessage = "Must select a model"; } else { unitOfWork = factory.UnitOfWorkFactory.CreateUnitOfWork(typeof(JunkCar.UnitOfWork.UOWs.HomeUOW)); home = (DomainModel.Models.Home)unitOfWork.Get(home,OperationTypeEnum.GET_A_BETTER_OFFER); home.ResponseMessage = "Valid"; } break; case DomainModelEnum.CONFIRM_OFFER: home = (DomainModel.Models.Home)domainModel; if (home.Name.Length <= 0) { home.ResponseMessage = "Please enter name"; } else if (home.Address.Length <= 0) { home.ResponseMessage = "Please enter address"; } else if (home.Phone.Length <= 0) { home.ResponseMessage = "Please enter phone number"; } else if (home.EmailAddress.Length <= 0) { home.ResponseMessage = "Please enter email address"; } else { if (home.OfferPrice.Contains("$")) { home.OfferPrice = home.OfferPrice.Replace("$",""); } unitOfWork = factory.UnitOfWorkFactory.CreateUnitOfWork(typeof(JunkCar.UnitOfWork.UOWs.HomeUOW)); home = (DomainModel.Models.Home)unitOfWork.Get(home,OperationTypeEnum.CONFIRM_OFFER); home.ResponseMessage = "Confirmed"; } break; case DomainModelEnum.CONFIRM_OFFER_WITH_QUESTIONNAIRE: home = (DomainModel.Models.Home)domainModel; if (home.Name.Length <= 0) { home.ResponseMessage = "Please enter name"; } else if (home.Address.Length <= 0) { home.ResponseMessage = "Please enter address"; } else if (home.Phone.Length <= 0) { home.ResponseMessage = "Please enter phone number"; } else if (home.EmailAddress.Length <= 0) { home.ResponseMessage = "Please enter email address"; } else { if (home.OfferPrice.Contains("$")) { home.OfferPrice = home.OfferPrice.Replace("$", ""); } unitOfWork = factory.UnitOfWorkFactory.CreateUnitOfWork(typeof(JunkCar.UnitOfWork.UOWs.HomeUOW)); home = (DomainModel.Models.Home)unitOfWork.Get(home,OperationTypeEnum.CONFIRM_OFFER_WITH_QUESTIONNAIRE); home.ResponseMessage = "Confirmed"; } break; case DomainModelEnum.GET_CUSTOMER_ID: home = (DomainModel.Models.Home)domainModel; if (home.EmailAddress.Length <= 0) { home.ResponseMessage = "Please enter email address"; } else { unitOfWork = factory.UnitOfWorkFactory.CreateUnitOfWork(typeof(JunkCar.UnitOfWork.UOWs.HomeUOW)); home = (DomainModel.Models.Home)unitOfWork.Get(home, OperationTypeEnum.GET_CUSTOMER_ID); home.ResponseMessage = "Found"; } break; default: break; } } else { switch (domainModelType) { case DomainModelEnum.GET_MAKES: home.ResponseMessage = "Invalid domain model"; break; case DomainModelEnum.GET_MODELS: home.ResponseMessage = "Invalid domain model"; break; case DomainModelEnum.CHECK_ZIPCODE: home.ResponseMessage = "Invalid domain model"; break; case DomainModelEnum.GET_CITIES: home.ResponseMessage = "Invalid domain model"; break; case DomainModelEnum.GET_AN_OFFER: home.ResponseMessage = "Invalid domain model"; break; case DomainModelEnum.GET_A_BETTER_OFFER: home.ResponseMessage = "Invalid domain model"; break; case DomainModelEnum.CONFIRM_OFFER: home.ResponseMessage = "Invalid domain model"; break; case DomainModelEnum.CONFIRM_OFFER_WITH_QUESTIONNAIRE: home.ResponseMessage = "Invalid domain model"; break; case DomainModelEnum.GET_CUSTOMER_ID: home.ResponseMessage = "Invalid domain model"; break; default: break; } } } catch (Exception ex) { switch (domainModelType) { case DomainModelEnum.GET_MAKES: home.ResponseMessage = ex.Message; break; case DomainModelEnum.GET_MODELS: home.ResponseMessage = ex.Message; break; case DomainModelEnum.CHECK_ZIPCODE: home.ResponseMessage = ex.Message; break; case DomainModelEnum.GET_CITIES: home.ResponseMessage = ex.Message; break; case DomainModelEnum.GET_AN_OFFER: home.ResponseMessage = ex.Message; break; case DomainModelEnum.GET_A_BETTER_OFFER: home.ResponseMessage = ex.Message; break; case DomainModelEnum.CONFIRM_OFFER: home.ResponseMessage = ex.Message; break; case DomainModelEnum.CONFIRM_OFFER_WITH_QUESTIONNAIRE: home.ResponseMessage = ex.Message; break; case DomainModelEnum.GET_CUSTOMER_ID: home.ResponseMessage = ex.Message; break; default: break; } } switch (domainModelType) { case DomainModelEnum.GET_MAKES: return home; case DomainModelEnum.GET_MODELS: return home; case DomainModelEnum.CHECK_ZIPCODE: return home; case DomainModelEnum.GET_CITIES: return home; case DomainModelEnum.GET_AN_OFFER: return home; case DomainModelEnum.GET_A_BETTER_OFFER: return home; case DomainModelEnum.CONFIRM_OFFER: return home; case DomainModelEnum.CONFIRM_OFFER_WITH_QUESTIONNAIRE: return home; case DomainModelEnum.GET_CUSTOMER_ID: return home; default: break; } return null; // Just to fullfill the syntactical requirements, this return will never be hit in any case. }
public override AbstractDomainModel Delete(AbstractDomainModel domainModel, DomainModelEnum domainModelType) { throw new NotImplementedException(); }
public override AbstractDomainModel Query(AbstractDomainModel domainModel, DomainModelEnum domainModelType, SearchCriteriaEnum searchCriteria) { throw new NotImplementedException(); }
public abstract AbstractDomainModel Query(AbstractDomainModel domainModel, DomainModelEnum domainModelType);
public abstract AbstractDomainModel Query(AbstractDomainModel domainModel, DomainModelEnum domainModelType, JunkCar.Core.Enumerations.SearchCriteriaEnum searchCriteria);
public abstract AbstractDomainModel Update(AbstractDomainModel domainModel, DomainModelEnum domainModelType);
public abstract AbstractDomainModel Delete(AbstractDomainModel domainModel, DomainModelEnum domainModelType);
public abstract AbstractDomainModel Save(AbstractDomainModel domainModel, DomainModelEnum domainModelType);
public override AbstractDomainModel Update(AbstractDomainModel domainModel, DomainModelEnum domainModelType) { try { if (domainModel != null) { switch (domainModelType) { case DomainModelEnum.CHANGE_PASSWORD: changePassword = (DomainModel.Models.ChangePassword)domainModel; if (changePassword.UserId == null || changePassword.UserId.Length <= 0) { changePassword.ResponseMessage = "Email is required"; } else if (changePassword.OldPassword == null || changePassword.OldPassword.Length <= 0) { changePassword.ResponseMessage = "Old Password is required"; } else if (changePassword.NewPassword == null || changePassword.NewPassword.Length <= 0) { changePassword.ResponseMessage = "New Password is required"; } else { FactoryFacade factory = new FactoryFacade(); unitOfWork = factory.UnitOfWorkFactory.CreateUnitOfWork(typeof(JunkCar.UnitOfWork.UOWs.AccountsUOW)); changePassword = (DomainModel.Models.ChangePassword)unitOfWork.Get(changePassword, OperationTypeEnum.CHANGE_PASSWORD); changePassword.ResponseMessage = "Valid"; } break; case DomainModelEnum.EDIT_PROFILE: editProfile = (DomainModel.Models.EditProfile)domainModel; if (editProfile.UserId == null || editProfile.UserId.Length <= 0) { editProfile.ResponseMessage = "Email is required"; } //if (userProfile.userProfile == null || userProfile.OldPassword.Length <= 0) //{ changePassword.ResponseMessage = "Old Password is required"; } //else if (changePassword.NewPassword == null || changePassword.NewPassword.Length <= 0) //{ changePassword.ResponseMessage = "New Password is required"; } else { FactoryFacade factory = new FactoryFacade(); unitOfWork = factory.UnitOfWorkFactory.CreateUnitOfWork(typeof(JunkCar.UnitOfWork.UOWs.AccountsUOW)); editProfile = (DomainModel.Models.EditProfile)unitOfWork.Get(editProfile, OperationTypeEnum.EDIT_PROFILE); editProfile.ResponseMessage = "Valid"; } break; default: break; } } else { switch (domainModelType) { case DomainModelEnum.CHANGE_PASSWORD: changePassword.ResponseMessage = "Invalid domain model"; break; case DomainModelEnum.EDIT_PROFILE: editProfile.ResponseMessage = "Invalid domain model"; break; default: break; } } } catch (Exception ex) { switch (domainModelType) { case DomainModelEnum.CHANGE_PASSWORD: changePassword.ResponseMessage = ex.Message; break; case DomainModelEnum.EDIT_PROFILE: editProfile.ResponseMessage = ex.Message; break; default: break; } } switch (domainModelType) { case DomainModelEnum.CHANGE_PASSWORD: return(changePassword); case DomainModelEnum.EDIT_PROFILE: return(editProfile); default: break; } return(null); }
public override AbstractDomainModel Query(AbstractDomainModel domainModel, DomainModelEnum domainModelType) { try { if (domainModel != null) { switch (domainModelType) { case DomainModelEnum.AUTHENTICATE: authenticate = (DomainModel.Models.Authenticate)domainModel; if (authenticate.Email == null || authenticate.Email.Length <= 0) { authenticate.ResponseMessage = "Email is required"; } else if (authenticate.Password == null || authenticate.Password.Length <= 0) { authenticate.ResponseMessage = "Password is required"; } else { FactoryFacade factory = new FactoryFacade(); unitOfWork = factory.UnitOfWorkFactory.CreateUnitOfWork(typeof(JunkCar.UnitOfWork.UOWs.AccountsUOW)); authenticate = (DomainModel.Models.Authenticate)unitOfWork.Get(authenticate, OperationTypeEnum.AUTHENTICATE); authenticate.ResponseMessage = "Valid"; } break; case DomainModelEnum.GET_SECURITY_QUESTION: forgotPassword = (DomainModel.Models.ForgotPassword)domainModel; if (forgotPassword.UserId == null || forgotPassword.UserId.Length <= 0) { forgotPassword.ResponseMessage = "User id is required"; } else { FactoryFacade factory = new FactoryFacade(); unitOfWork = factory.UnitOfWorkFactory.CreateUnitOfWork(typeof(JunkCar.UnitOfWork.UOWs.AccountsUOW)); forgotPassword = (DomainModel.Models.ForgotPassword)unitOfWork.Get(forgotPassword, OperationTypeEnum.GET_SECURITY_QUESTION); forgotPassword.ResponseMessage = "Valid"; } break; case DomainModelEnum.CHECK_SECURITY_QUESTION_ANSWER: forgotPassword = (DomainModel.Models.ForgotPassword)domainModel; if (forgotPassword.SecurityQuestionAnswer == null || forgotPassword.SecurityQuestionAnswer.Length <= 0) { forgotPassword.ResponseMessage = "Please answer the given question"; } else { FactoryFacade factory = new FactoryFacade(); unitOfWork = factory.UnitOfWorkFactory.CreateUnitOfWork(typeof(JunkCar.UnitOfWork.UOWs.AccountsUOW)); forgotPassword = (DomainModel.Models.ForgotPassword)unitOfWork.Get(forgotPassword, OperationTypeEnum.CHECK_SECURITY_QUESTION_ANSWER); } break; case DomainModelEnum.CHECK_VERIFICATION_CODE: forgotPassword = (DomainModel.Models.ForgotPassword)domainModel; if (forgotPassword.VerificationCode == 0) { forgotPassword.ResponseMessage = "Please enter the given verification code"; } else { FactoryFacade factory = new FactoryFacade(); unitOfWork = factory.UnitOfWorkFactory.CreateUnitOfWork(typeof(JunkCar.UnitOfWork.UOWs.AccountsUOW)); forgotPassword = (DomainModel.Models.ForgotPassword)unitOfWork.Get(forgotPassword, OperationTypeEnum.CHECK_VERIFICATION_CODE); } break; case DomainModelEnum.RESET_PASSWORD: forgotPassword = (DomainModel.Models.ForgotPassword)domainModel; if (forgotPassword.NewPassword == null || forgotPassword.NewPassword.Length <= 0) { forgotPassword.ResponseMessage = "Please enter new password"; } else { FactoryFacade factory = new FactoryFacade(); unitOfWork = factory.UnitOfWorkFactory.CreateUnitOfWork(typeof(JunkCar.UnitOfWork.UOWs.AccountsUOW)); forgotPassword = (DomainModel.Models.ForgotPassword)unitOfWork.Get(forgotPassword, OperationTypeEnum.RESET_PASSWORD); } break; case DomainModelEnum.CHECK_USER_ID: authenticate = (DomainModel.Models.Authenticate)domainModel; if (authenticate.Email == null || authenticate.Email.Length <= 0) { authenticate.ResponseMessage = "Please enter valid email"; } else { FactoryFacade factory = new FactoryFacade(); unitOfWork = factory.UnitOfWorkFactory.CreateUnitOfWork(typeof(JunkCar.UnitOfWork.UOWs.AccountsUOW)); authenticate = (DomainModel.Models.Authenticate)unitOfWork.Get(authenticate, OperationTypeEnum.CHECK_USER_ID); } break; case DomainModelEnum.GET_USER_INFO: userProfile = (DomainModel.Models.UserProfile)domainModel; if (userProfile.UserId == null || userProfile.UserId.Length <= 0) { userProfile.ResponseMessage = "Please enter valid email"; } else { FactoryFacade factory = new FactoryFacade(); unitOfWork = factory.UnitOfWorkFactory.CreateUnitOfWork(typeof(JunkCar.UnitOfWork.UOWs.AccountsUOW)); userProfile = (DomainModel.Models.UserProfile)unitOfWork.Get(userProfile, OperationTypeEnum.GET_USER_INFO); } break; default: break; } } else { switch (domainModelType) { case DomainModelEnum.AUTHENTICATE: authenticate.ResponseMessage = "Invalid domain model"; break; case DomainModelEnum.GET_SECURITY_QUESTION: forgotPassword.ResponseMessage = "Invalid domain model"; break; case DomainModelEnum.CHECK_SECURITY_QUESTION_ANSWER: forgotPassword.ResponseMessage = "Invalid domain model"; break; case DomainModelEnum.CHECK_VERIFICATION_CODE: forgotPassword.ResponseMessage = "Invalid domain model"; break; case DomainModelEnum.RESET_PASSWORD: forgotPassword.ResponseMessage = "Invalid domain model"; break; case DomainModelEnum.CHECK_USER_ID: authenticate.ResponseMessage = "Invalid domain model"; break; case DomainModelEnum.GET_USER_INFO: userProfile.ResponseMessage = "Invalid domain model"; break; default: break; } } } catch (Exception ex) { switch (domainModelType) { case DomainModelEnum.AUTHENTICATE: authenticate.ResponseMessage = ex.Message; break; case DomainModelEnum.GET_SECURITY_QUESTION: forgotPassword.ResponseMessage = ex.Message; break; case DomainModelEnum.CHECK_SECURITY_QUESTION_ANSWER: forgotPassword.ResponseMessage = ex.Message; break; case DomainModelEnum.CHECK_VERIFICATION_CODE: forgotPassword.ResponseMessage = ex.Message; break; case DomainModelEnum.RESET_PASSWORD: forgotPassword.ResponseMessage = ex.Message; break; case DomainModelEnum.CHECK_USER_ID: authenticate.ResponseMessage = ex.Message; break; case DomainModelEnum.GET_USER_INFO: userProfile.ResponseMessage = ex.Message; break; default: break; } } switch (domainModelType) { case DomainModelEnum.AUTHENTICATE: return(authenticate); case DomainModelEnum.GET_SECURITY_QUESTION: return(forgotPassword); case DomainModelEnum.CHECK_SECURITY_QUESTION_ANSWER: return(forgotPassword); case DomainModelEnum.CHECK_VERIFICATION_CODE: return(forgotPassword); case DomainModelEnum.RESET_PASSWORD: return(forgotPassword); case DomainModelEnum.CHECK_USER_ID: return(authenticate); case DomainModelEnum.GET_USER_INFO: return(userProfile); default: break; } return(null); }
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); }
public override AbstractDomainModel Query(AbstractDomainModel domainModel, DomainModelEnum domainModelType) { DomainModel.Models.ContactUs contactUs = (DomainModel.Models.ContactUs)domainModel; try { FactoryFacade factory = new FactoryFacade(); if (domainModel != null) { switch (domainModelType) { case DomainModelEnum.CONTACT_EMAIL_MESSAGE: if (contactUs.Email == null || contactUs.Email.Length <= 0) { contactUs.ResponseMessage = "Email is required"; } else if (contactUs.Name == null || contactUs.Name.Length <= 0) { contactUs.ResponseMessage = "Name is required"; } else { unitOfWork = factory.UnitOfWorkFactory.CreateUnitOfWork(typeof(JunkCar.UnitOfWork.UOWs.ContactUsUOW)); contactUs = (DomainModel.Models.ContactUs)unitOfWork.Get(contactUs, OperationTypeEnum.CONTACT_EMAIL_MESSAGE); contactUs.ResponseMessage = "Valid"; } break; case DomainModelEnum.CHECK_ZIPCODE: contactUs = (DomainModel.Models.ContactUs)domainModel; if (contactUs.ZipCode == null || contactUs.ZipCode == "" || contactUs.ZipCode == string.Empty) { contactUs.ResponseMessage = "Must enter a zipcode"; } else { unitOfWork = factory.UnitOfWorkFactory.CreateUnitOfWork(typeof(JunkCar.UnitOfWork.UOWs.ContactUsUOW)); contactUs = (DomainModel.Models.ContactUs)unitOfWork.Get(contactUs, OperationTypeEnum.CHECK_ZIPCODE); contactUs.ResponseMessage = "Valid"; } break; default: break; } } else { switch (domainModelType) { case DomainModelEnum.CONTACT_EMAIL_MESSAGE: contactUs.ResponseMessage = "Invalid domain model"; break; case DomainModelEnum.CHECK_ZIPCODE: contactUs.ResponseMessage = "Invalid domain model"; break; default: break; } } } catch (Exception ex) { switch (domainModelType) { case DomainModelEnum.CONTACT_EMAIL_MESSAGE: contactUs.ResponseMessage = ex.Message; break; case DomainModelEnum.CHECK_ZIPCODE: contactUs.ResponseMessage = ex.Message; break; default: break; } } switch (domainModelType) { case DomainModelEnum.CONTACT_EMAIL_MESSAGE: return(contactUs); case DomainModelEnum.CHECK_ZIPCODE: return(contactUs); default: break; } return(null); }