public ProviderDataAccessTests() { providerData = new ProviderDataAccess(); }
public ProviderBusinessLogic() { this.providerDataAccess = new ProviderDataAccess(); }
/// <summary> /// Page Load Event Handler. Call every time when the page is loaded. /// </summary> /// <param name="sender">Sender object</param> /// <param name="e">EventArgs</param> protected void Page_Load(object sender, EventArgs e) { //reset the error message label lblMsg.Text = ""; lblMsg.ForeColor = System.Drawing.Color.Red; //set focus the first textbox txtOrganization.Focus(); if (!IsPostBack) { //default set the status "Active" radStatus.SelectedIndex = 0; //Load the state list populateStateList(); //check weather it is in edit provider mode if (Request.QueryString[LACESConstant.QueryString.PROVIDER_ID] != null) { try { //get the provider id from query string long providerID = Convert.ToInt64(Request.QueryString[LACESConstant.QueryString.PROVIDER_ID]); //get provider object from DAL Provider1 currentProvider = new Provider1(); currentProvider.ID = providerID; ProviderDataAccess oProviderDataAccess = new ProviderDataAccess(); currentProvider = oProviderDataAccess.GetById(currentProvider.ID); //check weather the provider is exist if (currentProvider != null) { txtOrganization.Text = currentProvider.Organization; txtStreetAddress.Text = currentProvider.StreetAddress; txtCity.Text = currentProvider.City; drpState.SelectedValue = currentProvider.State.Trim(); txtZip.Text = currentProvider.Zip; txtCountry.Text = currentProvider.Country; txtPhone.Text = currentProvider.Phone; txtFax.Text = currentProvider.Fax; txtWebsite.Text = currentProvider.Website; txtIndName.Text = currentProvider.IndividualsName; txtIndPosition.Text = currentProvider.IndividualsPosition; txtIndPhone.Text = currentProvider.IndividualsPhone; txtIndFax.Text = currentProvider.IndividualsFax; txtEmail.Text = currentProvider.IndividualsEmail; radStatus.SelectedValue = currentProvider.Status.Trim(); //set the password fields txtPassword.Attributes.Add("value", LACESUtilities.Decrypt(currentProvider.IndividualsPassword)); txtPasswordConfirm.Attributes.Add("value", LACESUtilities.Decrypt(currentProvider.IndividualsPassword)); } else { //show error message lblMsg.Text = LACESConstant.Messages.PROVIDER_NOT_FOUND_IN_ADMIN; lblMsg.ForeColor = System.Drawing.Color.Red; } } catch (Exception ex) { throw ex; } } } }
/// <summary> /// Call every time when user click on Save Details button. /// </summary> /// <param name="sender">sender object</param> /// <param name="e">EventArgs</param> protected void btnSaveDetails_Click(object sender, EventArgs e) { //create Provider Data Access object ProviderDataAccess oProviderDataAccess = new ProviderDataAccess(); //Check for existence for Email address Provider1 oProvider = oProviderDataAccess.GetbyEmail(txtEmail.Text); //now check weather it is in edit provider mode if (Request.QueryString[LACESConstant.QueryString.PROVIDER_ID] != null) { //get the provider id from query string long providerID = Convert.ToInt64(Request.QueryString[LACESConstant.QueryString.PROVIDER_ID]); //check weather it is the same person if (oProvider != null && oProvider.ID == providerID) { oProvider = null; } } if (oProvider == null) { // The email is not already used, means the current provider can use the email Provider1 currentProvider = new Provider1(); currentProvider.Organization = txtOrganization.Text.Trim(); currentProvider.StreetAddress = txtStreetAddress.Text.Trim(); currentProvider.City = txtCity.Text.Trim(); currentProvider.State = drpState.SelectedValue.Trim(); currentProvider.Zip = txtZip.Text.Trim(); currentProvider.Country = txtCountry.Text.Trim(); currentProvider.Phone = txtPhone.Text.Trim(); currentProvider.Fax = txtFax.Text.Trim(); currentProvider.Website = txtWebsite.Text.Trim(); currentProvider.IndividualsName = txtIndName.Text.Trim(); currentProvider.IndividualsPosition = txtIndPosition.Text.Trim(); currentProvider.IndividualsPhone = txtIndPhone.Text.Trim(); currentProvider.IndividualsFax = txtIndFax.Text.Trim(); currentProvider.IndividualsEmail = txtEmail.Text.Trim(); //set the password fields txtPassword.Attributes.Add("value", txtPassword.Text); txtPasswordConfirm.Attributes.Add("value", txtPasswordConfirm.Text); //Encode the password before saving the provider details information currentProvider.IndividualsPassword = LACESUtilities.Encrypt(txtPassword.Text); //set the provider status currentProvider.Status = radStatus.SelectedValue; //now check weather it is in edit provider mode if (Request.QueryString[LACESConstant.QueryString.PROVIDER_ID] != null) { //get the provider id from query string long providerID = Convert.ToInt64(Request.QueryString[LACESConstant.QueryString.PROVIDER_ID]); currentProvider.ID = providerID; if (oProviderDataAccess.Update(currentProvider) == null) { lblMsg.Text = "Cannot save data."; lblMsg.ForeColor = System.Drawing.Color.Red; } else { //data saved successfully so prepare and send mail to the respective provider if (SendMailToProvider(true)) { //send mail successfull lblMsg.Text = "Contact information updated successfully and email sent to the contact."; lblMsg.ForeColor = System.Drawing.Color.Green; } else { //send mail error lblMsg.Text = "Contact information updated successfully and email sent to the contact."; lblMsg.ForeColor = System.Drawing.Color.Green; } } } else //it is in add provider mode, so add a new provider { //all thing ok, so store provider into the DB if (oProviderDataAccess.Add(currentProvider) == null) { lblMsg.Text = "Cannot save data."; lblMsg.ForeColor = System.Drawing.Color.Red; } else { //data add successfully so prepare and send mail to the respective provider if (SendMailToProvider(false)) { //send mail successfull lblMsg.Text = "Contact information added successfully and email sent to the contact."; lblMsg.ForeColor = System.Drawing.Color.Green; } else { //send mail error lblMsg.Text = "Contact information added successfully and email sent to the contact."; lblMsg.ForeColor = System.Drawing.Color.Green; } clearForm(); } } } else { //The email is already used, so not allowed lblMsg.Text = "Email already exists. Please provide another email."; lblMsg.ForeColor = System.Drawing.Color.Red; txtEmail.Focus(); } }
/// <summary> /// Page Load event handler /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Page_Load(object sender, EventArgs e) { int iPageIndex = 0; int totalCount = 0; ProviderDataAccess oblProvDAL = new ProviderDataAccess(); //if no search keywords for provider found in the session then redirect to the FindProviders.aspx page if (Session[LACESConstant.SessionKeys.SEARCH_PROVIDERS_KEYWORDS] == null) { Response.Redirect("FindProviders.aspx"); } lblMessage.Visible = false; ///Check Sort Column Query String if (Request.QueryString[LACESConstant.QueryString.SORT_COLUMN] != null) { sSortColumn = Request.QueryString[LACESConstant.QueryString.SORT_COLUMN].ToString(); } else { sSortColumn = "Organization"; } ///Check Sort Order Query String if (Request.QueryString[LACESConstant.QueryString.SORT_ORDER] != null) { sSortOrder = Request.QueryString[LACESConstant.QueryString.SORT_ORDER].ToString(); } else { sSortOrder = "asc"; } ///Check Current Page Index Query String if (Request.QueryString[LACESConstant.QueryString.PAGE_INDEX] != null) { iPageIndex = Convert.ToInt32(Request.QueryString[LACESConstant.QueryString.PAGE_INDEX].ToString()); } else { iPageIndex = 0; } ///Create Header row //createHeaderRow(sSortColumn, sSortOrder,iPageIndex); ///Adjust left/right content place holder width IncreaseLeftContentWidth(); providers = oblProvDAL.GetPagedProviderSearch(buildSearchCriteria(), iPageIndex, LACESConstant.SEARCH_RESULT_PAGE_SIZE, sSortColumn, sSortOrder, ref totalCount); string resultsNumber = ""; if (iPageIndex == 0) { resultsNumber = "1 -"; } else { resultsNumber = ((iPageIndex * 10) + 1).ToString() + " - "; } int pageMax = ((iPageIndex + 1) * LACESConstant.SEARCH_RESULT_PAGE_SIZE); if (pageMax <= totalCount) { resultsNumber += ((iPageIndex + 1) * 10).ToString(); } else { resultsNumber += totalCount.ToString(); } uiLitResultsMessage.Text = "Search Results: " + resultsNumber + " out of " + totalCount.ToString() + " results"; ///Show selecterd criteria in right side //showSelectedCriteria(totalCount); ///Generate PreviousPage NextPage link setPreviousNextPage(iPageIndex, totalCount); }
public ProviderService() { providerData = new ProviderDataAccess(); }
/// <summary> /// Call every time when user click on 'Save Details' button. /// </summary> /// <param name="sender">sender object</param> /// <param name="e">EventArgs</param> protected void btnSaveDetails_Click(object sender, EventArgs e) { //create Provider Data Access object ProviderDataAccess oProviderDataAccess = new ProviderDataAccess(); //Check for existence for Email address Provider1 oProvider = oProviderDataAccess.GetbyEmail(txtEmail.Text); //now check weather it is in edit provider mode if (Session[LACESConstant.SessionKeys.LOGEDIN_PROVIDER] != null) { //get the provider from session Provider1 currentProvider = (Provider1)Session[LACESConstant.SessionKeys.LOGEDIN_PROVIDER]; // Get provider information from Session //check weather it is the same person if (oProvider != null && oProvider.ID == currentProvider.ID) { oProvider = null; } } if (oProvider == null) { // The email is not already used, means the current provider can use the email Provider1 currentProvider = new Provider1(); currentProvider.Organization = txtOrganization.Text.Trim(); currentProvider.StreetAddress = txtStreetAddress.Text.Trim(); currentProvider.City = txtCity.Text.Trim(); currentProvider.State = drpState.SelectedValue.Trim(); currentProvider.Zip = txtZip.Text.Trim(); currentProvider.Country = txtCountry.Text.Trim(); currentProvider.Phone = txtPhone.Text.Trim(); currentProvider.Fax = txtFax.Text.Trim(); currentProvider.Website = txtWebsite.Text.Trim(); currentProvider.IndividualsName = txtIndName.Text.Trim(); currentProvider.IndividualsPosition = txtIndPosition.Text.Trim(); currentProvider.IndividualsPhone = txtIndPhone.Text.Trim(); currentProvider.IndividualsFax = txtIndFax.Text.Trim(); currentProvider.IndividualsEmail = txtEmail.Text.Trim(); //set the password fields txtPassword.Attributes.Add("value", txtPassword.Text); txtPasswordConfirm.Attributes.Add("value", txtPasswordConfirm.Text); //Encode the password before saving the provider details information currentProvider.IndividualsPassword = LACESUtilities.Encrypt(txtPassword.Text); //set the provider status //currentProvider.Status = "Y"; //now check session variable if (Session[LACESConstant.SessionKeys.LOGEDIN_PROVIDER] != null) { //get the provider id from query string long providerID = ((Provider1)Session[LACESConstant.SessionKeys.LOGEDIN_PROVIDER]).ID; currentProvider.ID = providerID; currentProvider = oProviderDataAccess.Update(currentProvider); if (currentProvider == null) { lblMsg.Text = "Cannot save data."; lblMsg.ForeColor = System.Drawing.Color.Red; } else { //send mail successfull lblMsg.Text = "Contact information updated successfully."; lblMsg.ForeColor = System.Drawing.Color.Green; //update the current provider information in the session Session[LACESConstant.SessionKeys.LOGEDIN_PROVIDER] = currentProvider; //populate provider updated information from session populateProviderInformation(); } } } else { //The email is already used, so not allowed lblMsg.Text = "Email already exists. Please provide another email."; lblMsg.ForeColor = System.Drawing.Color.Red; txtEmail.Focus(); } }