public async Task <IActionResult> Edit(int id, [Bind("ID,Postcode,City,State")] EAddress eAddress)
        {
            if (id != eAddress.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(eAddress);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!EAddressExists(eAddress.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(eAddress));
        }
        public async Task <IActionResult> Create([Bind("ID,Postcode,City,State")] EAddress eAddress)
        {
            if (ModelState.IsValid)
            {
                _context.Add(eAddress);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(eAddress));
        }
Пример #3
0
 internal static VM_EAddress EAddress_To_VMEAddress(EAddress eAddress)
 {
     logger.EnterMethod();
     try
     {
         return(new VM_EAddress()
         {
             Id = eAddress.Id,
             Email = eAddress.Email,
             NumberPhone = eAddress.NumberPhone,
             StaffId = eAddress.StaffId,
             Website = eAddress.Website
         });
     }
     catch (Exception e)
     {
         logger.Error("Error: [" + e.Message + "]");
         return(new VM_EAddress());
     }
     finally
     {
         logger.LeaveMethod();
     }
 }
Пример #4
0
        public void WritePacket(Packet packet)
        {
            packet.WriteUInt32(Id);
            packet.WriteUTF8String(Misc.GetTaxiTypeString(Type));
            packet.WriteUTF8String(Misc.GetOrderStatusString(Status));
            packet.WriteUInt32((uint)Time.UnixTimeFromDataTime(Date));
            packet.WriteUTF8String(SAddress.ToString());
            packet.WriteUTF8String(EAddress.ToString());
            packet.WriteUTF8String(Owner.Username);

            if (Driver != null)
            {
                packet.WriteUInt8(1);
                packet.WriteUTF8String(Driver.Username);
                packet.WriteUTF8String(Driver.ToDriver().Car.Model);
                packet.WriteUTF8String(Driver.ToDriver().Car.Color);
                packet.WriteUTF8String(Driver.ToDriver().Car.Number);
                packet.WriteUTF8String(Misc.GetTaxiTypeString(Driver.ToDriver().Car.Type));
            }
            else
            {
                packet.WriteUInt8(0);
            }
        }
Пример #5
0
 public bool CreateEAddress(EAddress eAddress)
 {
     logger.EnterMethod();
     try
     {
         using (TransactionScope transactionScope = new TransactionScope(TransactionScopeOption.Required))
         {
             this._eaddressRepositories.Add(eAddress);
             transactionScope.Complete();
         }
         this._iUnitOfWork.Save();
         logger.Info("Create EAddress with email: [" + eAddress.Email + "], phone: [" + eAddress.NumberPhone + "], website: [" + eAddress.Website + "] for [" + eAddress.StaffId + "]");
         return(true);
     }
     catch (Exception e)
     {
         logger.Error("Error: [" + e.Message + "]");
         return(false);
     }
     finally
     {
         logger.LeaveMethod();
     }
 }
Пример #6
0
        public void sendMessage()
        {
            MailMessage mail = new MailMessage();

            client = new SmtpClient(this.Host, this.PortNumber);
            client.SendCompleted += new SendCompletedEventHandler(SendCompletedCallback);

            if (this.DisplayName.Length > 0)
            {
                mail.From = new MailAddress(this.FromAddress, this.DisplayName);
            }
            else
            {
                mail.From = new MailAddress(this.FromAddress);
            }


            string[] items = this.ToAddress.Split(';');
            if (items.Length > 0)
            {
                foreach (string EAddress in items)
                {
                    if (EAddress.Length > 0)
                    {
                        mail.To.Add(EAddress.Trim());
                    }
                }
            }
            else
            {
                mail.To.Add(this.ToAddress.Trim());
            }



            mail.Subject = this.Subject;
            mail.Body    = this.Body;

            ////Depreciated will be remove soon - 10 April 2017
            //if (_Attachments != null)
            //{
            //    foreach (Attachment myAttachment in _Attachments)
            //    { mail.Attachments.Add(myAttachment); }
            //}

            if (EmailAttachments != null)
            {
                List <int> AddFileID = new List <int>();
                foreach (EmailAttachmentMetaData myAttachment in EmailAttachments)
                {
                    if (myAttachment.CurrentAttachmentType == AttachmentType.PathBasedAttachment)
                    {
                        mail.Attachments.Add(new Attachment(myAttachment.AttachmentPath));
                    }
                    if (myAttachment.CurrentAttachmentType == AttachmentType.DatabaseImageAttachment)
                    {
                        try
                        {
                            using (var Dbconnection = new MCDEntities())
                            {
                                Data.Models.File FileImage = (from a in Dbconnection.Files
                                                              where a.FileID == myAttachment.DatabaseFileID
                                                              select a).FirstOrDefault();

                                MemoryStream ms        = new MemoryStream(FileImage.FileImage);
                                string       sFileName = FileImage.FileName + "." + FileImage.FileExtension;
                                mail.Attachments.Add(new Attachment(ms, sFileName));
                            };
                        }
                        catch (Exception ex)
                        {
                            System.Windows.Forms.MessageBox.Show("Error getting attachment from database : " + ex.Message);
                        }
                    }
                }
            }


            if (RequireAuthentication)
            {
                client.Credentials = new System.Net.NetworkCredential(UserName, Password);
            }
            if (this.RequireSSL)
            {
                client.EnableSsl = true;
            }

            int retryCount = 0;;

            try
            {
                // string userState = "test message1";

                client.SendAsync(mail, "Start");
            }
            catch (SmtpFailedRecipientsException ex)
            {
                for (int i = 0; i < ex.InnerExceptions.Length; i++)
                {
                    SmtpStatusCode status = ex.InnerExceptions[i].StatusCode;
                    if (status == SmtpStatusCode.MailboxBusy || status == SmtpStatusCode.MailboxUnavailable)
                    {
                        System.Windows.Forms.MessageBox.Show("Delivery failed - retrying in 5 seconds. Retry Attempt " + retryCount + 1 + "of 3.", "Connection Error", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error, System.Windows.Forms.MessageBoxDefaultButton.Button1);
                        //System.Threading.Thread.Sleep(1);
                        if (retryCount < 2)
                        {
                            string userState = "test message1";
                            client.SendAsync(mail, userState);
                        }
                    }
                    else
                    {
                        System.Windows.Forms.MessageBox.Show("Failed to deliver message to {0}",
                                                             ex.InnerExceptions[i].FailedRecipient, System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
                    }
                }
            }
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show("Exception caught in RetryIfBusy(): {0}",
                                                     ex.ToString(), System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
            }
        }
Пример #7
0
    /// <summary>
    /// Save Prospect
    /// </summary>
    private void SaveProspect()
    {
        //FranchisorService service = new FranchisorService();
        EProspect        prospect            = new EProspect();
        EAddress         addressbilling      = new EAddress();
        EAddress         addressmailing      = new EAddress();
        EProspectDetails objEProspectDetails = new EProspectDetails();

        prospect.ProspectDetails = new EProspectDetails();
        bool blnIsHost = false;

        OtherDAL otherDal      = new OtherDAL();
        EZip     zipobjbilling = otherDal.CheckCityZip(txtcityBilling.Text, txtzipBilling.Text, ddlstateBilling.SelectedValue);

        EZip zipobjmailing = new EZip();

        // format phone no.
        CommonCode objCommonCode = new CommonCode();

        if (txtzipBilling.Text != "")
        {
            if (zipobjbilling.CityID == 0)
            {
                divErrorMsg.Visible   = true;
                divErrorMsg.InnerHtml = "City name for address is not valid. <br> Please Try again.";

                //ClientScript.RegisterStartupScript(typeof(string), "jscodebilling", "alert('City name for billing address is not valid. <br> Please Try again.');", true);
                return;
            }
            else if (zipobjbilling.CityID > 0 && zipobjbilling.ZipID == 0)
            {
                divErrorMsg.Visible   = true;
                divErrorMsg.InnerHtml = "Address Zip code for the corresponding city is not valid. <br> Please Try again.";

                //ClientScript.RegisterStartupScript(typeof(string), "jscodebilling", "alert('Billing address Zip code for the corresponding city is not valid. <br> Please Try again.');", true);
                return;
            }
        }
        if (chkMailingAddress.Checked == true)
        {
            zipobjmailing = otherDal.CheckCityZip(txtcityMailing.Text, txtzipMailing.Text, ddlstateMailing.SelectedValue);
            if (txtzipMailing.Text != "")
            {
                if (zipobjmailing.CityID == 0)
                {
                    divErrorMsg.Visible   = true;
                    divErrorMsg.InnerHtml = "City name for mailing address is not valid. <br> Please Try again.";

                    //ClientScript.RegisterStartupScript(typeof(string), "jscodemailing", "alert('City name for mailing address is not valid. <br> Please Try again.');", true);
                    return;
                }
                else if (zipobjmailing.CityID > 0 && zipobjmailing.ZipID == 0)
                {
                    divErrorMsg.Visible   = true;
                    divErrorMsg.InnerHtml = "Mailing address Zip code for the corresponding city is not valid. <br> Please Try again.";

                    //ClientScript.RegisterStartupScript(typeof(string), "jscodemailing", "alert('Mailing address Zip code for the corresponding city is not valid. <br> Please Try again.');", true);
                    return;
                }
            }
        }

        if (ViewState["ProspectID"] != null)
        {
            prospect.ProspectID = Convert.ToInt32(ViewState["ProspectID"].ToString());
        }

        if (ViewState["AddressIDBilling"] != null)
        {
            addressbilling.AddressID = Convert.ToInt32(ViewState["AddressIDBilling"].ToString());
        }

        prospect.OrganizationName = txtOrgName.Text;
        prospect.WebSite          = txtwebaddress.Text;

        EProspectType prospecttype = new EProspectType();

        prospecttype.ProspectTypeID = Convert.ToInt32(ddlHostType.SelectedValue.ToString());
        prospect.ProspectType       = prospecttype;

        prospect.ActualMembership = txtActualMembers.Text.Length > 0 ? Convert.ToDecimal(txtActualMembers.Text) : 0;
        prospect.Attendance       = txtAttendence.Text.Length > 0 ? Convert.ToDecimal(txtAttendence.Text) : 0;

        prospect.EMailID   = txtEmail.Text;
        prospect.PhoneCell = "";
        if (txtcphoneoffice.Text.Trim().Equals("(___)-___-____"))
        {
            txtcphoneoffice.Text = "";
        }
        prospect.PhoneOffice = objCommonCode.FormatPhoneNumber(txtcphoneoffice.Text);
        prospect.PhoneOther  = "";

        prospect.Notes = txtNotes.Text;

        if (ViewState["IsHost"].ToString().Equals("1"))
        {
            prospect.IsHost = true;
            blnIsHost       = true;
        }
        else
        {
            prospect.IsHost = false;
        }

        addressbilling.Address1 = txtaddress1Billing.Text;
        addressbilling.Address2 = txtaddress2Billing.Text;


        if (Convert.ToInt32(ddlstateBilling.SelectedValue) > 0)
        {
            addressbilling.State   = ddlstateBilling.SelectedItem.Text;
            addressbilling.StateID = Convert.ToInt32(ddlstateBilling.SelectedItem.Value);
        }
        else
        {
            addressbilling.State = string.Empty;
        }

        addressbilling.ZipID = txtzipBilling.Text.Length > 0 ? Convert.ToInt32(txtzipBilling.Text) : 0;
        addressbilling.City  = txtcityBilling.Text;
        if (txtFax.Text.Trim().Equals("(___)-___-____"))
        {
            txtFax.Text = "";
        }
        addressbilling.Fax = objCommonCode.FormatPhoneNumber(txtFax.Text);

        prospect.Address = addressbilling;

        if (blnIsHost)
        {
            addressbilling.ZipID = txtzipBilling.Text.Length > 0 ? zipobjbilling.ZipID : 0;
        }
        else
        {
            addressbilling.ZipID = txtzipBilling.Text.Length > 0 ? Convert.ToInt32(txtzipBilling.Text) : 0;
        }

        addressbilling.CityID = txtcityBilling.Text.Length > 0 ? zipobjbilling.CityID : 0;

        addressbilling.Country   = COUNTRY_NAME;
        addressbilling.CountryID = COUNTRY_ID;

        // If mailing address is provided
        if (chkMailingAddress.Checked == true)
        {
            addressmailing.IsMailing = true;
            addressmailing.Address1  = txtaddress1Mailing.Text;
            addressmailing.Address2  = txtaddress2Mailing.Text;

            if (Convert.ToInt32(ddlstateMailing.SelectedValue) > 0)
            {
                addressmailing.State   = ddlstateMailing.SelectedItem.Text;
                addressmailing.StateID = Convert.ToInt32(ddlstateBilling.SelectedItem.Value);
            }
            else
            {
                addressmailing.State = string.Empty;
            }

            if (blnIsHost)
            {
                addressmailing.ZipID = txtzipMailing.Text.Length > 0 ? zipobjmailing.ZipID : 0;
            }
            else
            {
                addressmailing.ZipID = txtzipMailing.Text.Length > 0 ? Convert.ToInt32(txtzipMailing.Text) : 0;
            }

            addressmailing.City   = txtcityMailing.Text;
            addressmailing.CityID = txtcityMailing.Text.Length > 0 ? zipobjmailing.CityID : 0;
            addressmailing.Zip    = txtzipMailing.Text;
            addressmailing.Fax    = "";

            addressmailing.Country   = COUNTRY_NAME;
            addressmailing.CountryID = COUNTRY_ID;
        }
        // Mailing address is same as billing address
        else
        {
            addressmailing.Address1 = addressbilling.Address1;
            addressmailing.Address2 = addressbilling.Address2;
            addressmailing.City     = addressbilling.City;
            addressmailing.State    = addressbilling.State;
            addressmailing.Zip      = addressbilling.Zip;
            addressmailing.Country  = addressbilling.Country;

            addressmailing.CityID    = addressbilling.CityID;
            addressmailing.StateID   = addressbilling.StateID;
            addressmailing.ZipID     = addressbilling.ZipID;
            addressmailing.CountryID = addressbilling.CountryID;

            addressmailing.IsMailing = true;
        }

        if (ViewState["AddressIDMailing"] != null)
        {
            addressmailing.AddressID = Convert.ToInt32(ViewState["AddressIDMailing"].ToString());
        }

        prospect.AddressMailing  = addressmailing;
        prospect.FollowDate      = DateTime.Now.ToShortDateString();
        prospect.WillCommunicate = Convert.ToInt32(ddlFeederPromotionStatus.SelectedValue);
        if (ddlFeederPromotionStatus.SelectedValue.Equals("0"))
        {
            prospect.ReasonWillCommunicate = txtWillPromote.Text;
        }
        if (ViewState["FranchiseeID"] != null)
        {
            ArrayList arrtemp = (ArrayList)ViewState["FranchiseeID"];
            prospect.FranchiseeID = arrtemp;
            //prospect.FranchiseeID = arrtemp.ToArray();
        }


        objEProspectDetails.FacilitiesFee = txtFacilitiesFee.Text;

        string strPaymentMethod = string.Empty;

        foreach (ListItem li in chkPaymentMethod.Items)
        {
            if (li.Selected == true)
            {
                if (strPaymentMethod == "")
                {
                    strPaymentMethod = li.Value;
                }
                else
                {
                    strPaymentMethod = strPaymentMethod + "," + li.Value;
                }
            }
        }
        objEProspectDetails.PaymentMethod   = strPaymentMethod;
        objEProspectDetails.DepositsRequire = Convert.ToInt16(rbtnDepositsRequired.SelectedValue);

        if (rbtnDepositsRequired.SelectedValue.Equals("1"))
        {
            objEProspectDetails.DepositsAmount = txtAmount.Text.Length > 0 ? Convert.ToDecimal(txtAmount.Text) : 0.0m;
        }
        objEProspectDetails.WillHost       = Convert.ToInt16(ddlhostStatus.SelectedValue);
        objEProspectDetails.ViableHostSite = Convert.ToInt16(ddlViableHost.SelectedValue);
        objEProspectDetails.HostedInPast   = Convert.ToInt16(ddlHostedInPast.SelectedValue);
        if (ddlhostStatus.SelectedValue.Equals("0"))
        {
            objEProspectDetails.ReasonWillHost = txtWillHost.Text;
        }
        if (ddlViableHost.SelectedValue.Equals("0"))
        {
            objEProspectDetails.ReasonViableHostSite = txtViableHostSite.Text;
        }
        if (ddlHostedInPast.SelectedValue.Equals("0"))
        {
            objEProspectDetails.ReasonHostedInPast = txtHostInPast.Text;
        }
        if (ddlHostedInPast.SelectedValue.Equals("1"))
        {
            objEProspectDetails.HostedInPastWith = txtHostedInPast.Text;
        }

        if (ViewState["ProspectDetailsID"] != null)
        {
            objEProspectDetails.ProspectDetailID = Convert.ToInt32(ViewState["ProspectDetailsID"].ToString());
        }
        prospect.ProspectDetails = objEProspectDetails;

        prospect.ContactMeeting = null;
        prospect.ContactCall    = null;
        prospect.Task           = null;

        var currentSession = IoC.Resolve <ISessionContext>().UserSession;

        Session["Popup"] = "True";
        if (blnIsHost)
        {
            UpdateHostWithContacts(prospect, currentSession.UserId.ToString(), currentSession.CurrentOrganizationRole.OrganizationId.ToString(),
                                   currentSession.CurrentOrganizationRole.RoleId.ToString());
        }
        else
        {
            UpdateProspectWithContact(prospect, currentSession.UserId.ToString(), currentSession.CurrentOrganizationRole.OrganizationId.ToString(),
                                      currentSession.CurrentOrganizationRole.RoleId.ToString());
        }

        ClientScript.RegisterStartupScript(typeof(Page), "Edit Prospect Host", "<script language='javascript'  type='text/javascript' > CloseWindow(); </script>");
    }
Пример #8
0
    /// <summary>
    /// raise the Country dropdown index change event and Refill the
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    //protected void ddlCountry_SelectedIndexChanged(object sender, EventArgs e)
    //{
    //    DropDownList ddlcountry = (DropDownList)sender;
    //    FillState(ddlcountry.ID);
    //}
    /// <summary>
    /// Change the city dropdown on change the state
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    //protected void ddlState_SelectedIndexChanged(object sender, EventArgs e)
    //{
    //    DropDownList ddlstate = (DropDownList)sender;
    //    FillCity(ddlstate.ID);
    //}

    #endregion

    #region Methods

    /// <summary>
    /// this method save the MedicalVendor data to the database
    /// </summary>
    private void SaveMedicalVendor()
    {
        OtherDAL otherDal = new OtherDAL();
        EZip     objbuzip, objzip;

        objbuzip = otherDal.CheckCityZip(txtBuCity.Text, txtBZip.Text, ddlBState.SelectedValue);
        objzip   = otherDal.CheckCityZip(txtCity.Text, txtZip.Text, ddlState.SelectedValue);

        if (objbuzip.CityID == 0)
        {
            ClientScript.RegisterStartupScript(typeof(string), "bujscode", "alert('City name entered for bussiness address is not valid.');", true);
            return;
        }
        else if (objbuzip.CityID > 0 && objbuzip.ZipID == 0)
        {
            ClientScript.RegisterStartupScript(typeof(string), "bujscode", "alert('Zip Code entered for bussiness address, corresponding to its city name, is not valid.');", true);
            return;
        }

        if (objzip.CityID == 0)
        {
            ClientScript.RegisterStartupScript(typeof(string), "jscode", "alert('City name entered for contact address is not valid.');", true);
            return;
        }
        else if (objzip.CityID > 0 && objzip.ZipID == 0)
        {
            ClientScript.RegisterStartupScript(typeof(string), "jscode", "alert('Zip Code entered for contact address, corresponding to its city name, is not valid.');", true);
            return;
        }

        // format phone no.
        CommonCode objCommonCode = new CommonCode();

        //MVUserService service = new MVUserService();
        EMedicalVendor MedicalVendor = new EMedicalVendor();

        EAddress address  = new EAddress();
        EAddress Baddress = new EAddress();
        EUser    user     = new EUser();
        /// fill the default data. Edited data will be overwrite

        var currentSession = IoC.Resolve <ISessionContext>().UserSession;

        MedicalVendor = OrganizationUser.GetMedicalVendor(currentSession);
        MedicalVendor.BusinessName  = txtVName.Text;
        MedicalVendor.BusinessFax   = objCommonCode.FormatPhoneNumber(txtBFax.Text);
        MedicalVendor.BusinessPhone = objCommonCode.FormatPhoneNumber(txtBPhone.Text);
        MedicalVendor.Description   = txtMVDesc.Text;

        Baddress.Address1  = txtBAddress1.Text;
        Baddress.Address2  = txtBAddress2.Text;
        Baddress.CityID    = objbuzip.CityID;
        Baddress.StateID   = Convert.ToInt32(ddlBState.SelectedValue);
        Baddress.CountryID = Convert.ToInt32(hfBusinessCountryID.Value);
        Baddress.ZipID     = objbuzip.ZipID;

        MedicalVendor.BusinessAddress = Baddress;

        address.Address1  = txtAddress1.Text;
        address.Address2  = txtAddress2.Text;
        address.CityID    = objzip.CityID;
        address.StateID   = Convert.ToInt32(ddlState.SelectedValue);
        address.CountryID = Convert.ToInt32(hfCountryID.Value);
        address.ZipID     = objzip.ZipID;


        MedicalVendor.MVUser.User.FirstName   = txtFName.Text;
        MedicalVendor.MVUser.User.MiddleName  = txtMName.Text;
        MedicalVendor.MVUser.User.LastName    = txtLName.Text;
        MedicalVendor.MVUser.User.PhoneHome   = objCommonCode.FormatPhoneNumber(txtPhoneHome.Text);
        MedicalVendor.MVUser.User.PhoneOffice = objCommonCode.FormatPhoneNumber(txtPhoneOther.Text);
        MedicalVendor.MVUser.User.PhoneCell   = objCommonCode.FormatPhoneNumber(txtPhoneCell.Text);
        MedicalVendor.MVUser.User.EMail1      = txtEmail.Text;
        MedicalVendor.MVUser.User.EMail2      = txtEmail2.Text;
        MedicalVendor.MVUser.User.HomeAddress = address;
        MedicalVendor.MVUser.User.SSN         = txtSSN.Text;
        MedicalVendor.MVUser.User.DOB         = Convert.ToDateTime(txtDOB.Text).ToString();
        Ucupdatephotopanel1.GetAllImages();
        MedicalVendor.MVUser.MyPicture   = Ucupdatephotopanel1.MyImage;
        MedicalVendor.MVUser.TeamPicture = Ucupdatephotopanel1.TeamImage;
        //MedicalVendor.MVUser.OtherPictures = Ucupdatephotopanel1.Images.ToArray();
        MedicalVendor.MVUser.OtherPictures = Ucupdatephotopanel1.Images;

        MedicalVendor.SpecialInstruction = txtSplInstruction.Text;
        MedicalVendor.AccountHolder      = txtAccountHolder.Text;
        MedicalVendor.AccountNumber      = txtAccountNo.Text;
        MedicalVendor.AccountType        = txtAccountType.Text;
        MedicalVendor.BankName           = txtBankName.Text;
        MedicalVendor.RountingNumber     = txtRoutingNumber.Text;
        MedicalVendor.Memo        = txtMemo.Text;
        MedicalVendor.PaymentMode = (int)(Falcon.App.Core.Enum.EPaymentType)Enum.Parse(typeof(Falcon.App.Core.Enum.EPaymentType), ddlPayMode.SelectedItem.Value);
        MedicalVendor.Interval    = (int)(PaymentFrequency)Enum.Parse(typeof(PaymentFrequency), ddlInterval.SelectedItem.Value);


        Int64 returnresult;



        if ((ViewState["IsEdit"] != null) && (ViewState["IsEdit"].ToString() != string.Empty))
        {
            MedicalVendorDAL medicalvendorDAL = new MedicalVendorDAL();
            returnresult = medicalvendorDAL.SaveMedicalVendor(MedicalVendor, Convert.ToInt32(EOperationMode.Update), currentSession.CurrentOrganizationRole.OrganizationId.ToString());
            if (returnresult == 0)
            {
                returnresult = 9999991;
            }

            Response.RedirectUser(ResolveUrl("~/App/MedicalVendor/ProfilePage.aspx"));
        }
    }
Пример #9
0
        public bool CheckContactInformationExistingAndUpdateForPerson(ContactInformation contactInformation)
        {
            logger.EnterMethod();
            try
            {
                #region Create EAddress
                var      createEAddress = this.CreateEAddress(contactInformation.EAddress);
                EAddress eaddress       = new EAddress();
                if (createEAddress) // Inserted EAddress
                {
                    eaddress = this.Get(contactInformation.EAddress.NumberPhone, contactInformation.EAddress.Email, contactInformation.EAddress.Website);
                    logger.Info("Inserted EAddress: [" + eaddress.Id + "] for person: [" + eaddress.StaffId + "]");
                }
                else // Can't insert EAddress
                {
                    logger.Info("Can't insert EAddress");
                }
                #endregion

                var contactInforGot = this._contactInformationRepositories.Get(_ => _.PersonId == contactInformation.PersonId);
                var additionalInfo  = "";
                #region Check and create address
                var checkAdress   = CheckAddressExisting(contactInformation.Address);
                var checkDistrict = CheckDistrictExisting(contactInformation.Address.District);
                var checkProvince = CheckProvinceExisting(contactInformation.Address.District.Province);
                var checkCountry  = CheckCountryExisting(contactInformation.Address.District.Province.Country);

                bool rt = true;

                if (checkCountry)            // Found country
                {
                    if (checkProvince)       // Found province
                    {
                        if (checkDistrict)   // Found district
                        {
                            if (checkAdress) // Found address -> Existing adress in database. Using addressId for contactInforGot
                            {
                                additionalInfo += "Found address: [" + contactInformation.Address.AddressNumberNoAndStreet + "]. ";
                            }
                            else // Create address
                            {
                                var insertedAdd = this.CreateAddress(contactInformation.Address);
                                if (insertedAdd) // Inserted address
                                {
                                    additionalInfo += "Create address [" + ((Address)Get("Address", contactInformation.Address.AddressNumberNoAndStreet)).Id + "]. ";
                                }
                                else // Can't insert address
                                {
                                    additionalInfo += "Can't create address. ";
                                    rt              = false;
                                    goto RETURN_HERE;
                                }
                            }
                        }
                        else // Not found district. Create district, address fit district
                        {
                            var insertDistrict = this.CreateDistrict(contactInformation.Address.District);
                            if (insertDistrict) // Inserted district
                            {
                                var district = (District)this.Get("District", contactInformation.Address.District.DistrictName);
                                contactInforGot.Address.DistrictId = district.Id;
                                additionalInfo += "Create district [" + district.Id + "]. ";
                                var insertAddress = this.CreateAddress(contactInformation.Address);
                                if (insertAddress) // Inserted address
                                {
                                    additionalInfo += "Create address [" + ((Address)this.Get("Address", contactInformation.Address.AddressNumberNoAndStreet)).Id + "]";
                                }
                                else // Can't insert address
                                {
                                    additionalInfo += "Can't insert address";
                                    rt              = false;
                                    goto RETURN_HERE;
                                }
                            }
                            else // Can't insert district
                            {
                                additionalInfo += "Can't insert district. ";
                                rt              = false;
                                goto RETURN_HERE;
                            }
                        }
                    }
                    else // Not found province. Create province, district, address fit country
                    {
                        var insertProvince = this.CreateProvince(contactInformation.Address.District.Province);
                        if (insertProvince) // Inserted province
                        {
                            additionalInfo += "Create province [" + ((Province)this.Get("Province", contactInformation.Address.District.Province.ProvinceName)).Id + "]. ";

                            var insertDistrict = this.CreateDistrict(contactInformation.Address.District);
                            if (insertDistrict) // Inserted district
                            {
                                additionalInfo += "Create district [" + ((District)this.Get("District", contactInformation.Address.District.DistrictName)).Id + "]. ";

                                var insertAddress = this.CreateAddress(contactInformation.Address);
                                if (insertAddress) // Inserted address
                                {
                                    additionalInfo += "Create address [" + ((Address)this.Get("Address", contactInformation.Address.AddressNumberNoAndStreet)).Id + "]. ";
                                }
                                else // Can't insert address
                                {
                                    additionalInfo += "Can't create address. ";
                                    rt              = false;
                                    goto RETURN_HERE;
                                }
                            }
                            else // Can't insert district
                            {
                                additionalInfo += "Can't create district. ";
                                rt              = false;
                                goto RETURN_HERE;
                            }
                        }
                        else // Can't insert province
                        {
                            additionalInfo += "Can't create province. ";
                            rt              = false;
                            goto RETURN_HERE;
                        }
                    }
                }
                else // Not found country. Create everything
                {
                    var createCountry  = this.CreateCountry(contactInformation.Address.District.Province.Country);
                    var createProvince = this.CreateProvince(contactInformation.Address.District.Province);
                    var createDistrict = this.CreateDistrict(contactInformation.Address.District);
                    var createAddress  = this.CreateAddress(contactInformation.Address);

                    if (createCountry)             // Inserted country
                    {
                        if (createProvince)        // Inserted province
                        {
                            if (createDistrict)    // Inserted district
                            {
                                if (createAddress) // Inserted address
                                {
                                    additionalInfo += "Create address: [" + contactInformation.Address.AddressNumberNoAndStreet + "], district: [" + contactInformation.Address.District.DistrictName + "], province: [" + contactInformation.Address.District.Province.ProvinceName + "] and country: [" + contactInformation.Address.District.Province.Country.CountryName + "]. ";
                                }
                                else // Can't insert address
                                {
                                    additionalInfo += "Can't insert address. ";
                                    rt              = false;
                                    goto RETURN_HERE;
                                }
                            }
                            else // Can't insert district
                            {
                                additionalInfo += "Can't insert district. ";
                                rt              = false;
                                goto RETURN_HERE;
                            }
                        }
                        else // Can't insert province
                        {
                            additionalInfo += "Can't insert province. ";
                            rt              = false;
                            goto RETURN_HERE;
                        }
                    }
                    else // Can't insert country
                    {
                        additionalInfo += "Can't insert country. ";
                        rt              = false;
                        goto RETURN_HERE;
                    }
                }
                #endregion

                var addressInserted = this._addressRepositories.Get(_ => _.AddressNumberNoAndStreet == contactInformation.Address.AddressNumberNoAndStreet);
                #region Update contact information for person
                if (contactInforGot != null)
                {
                    contactInforGot.EAddress = eaddress;
                    contactInforGot.Address  = addressInserted;
                    using (TransactionScope transactionScope = new TransactionScope(TransactionScopeOption.Required))
                    {
                        contactInforGot.Address                             = addressInserted;
                        contactInforGot.AddressId                           = addressInserted.Id;
                        contactInforGot.EAddress                            = eaddress;
                        contactInforGot.EAdressId                           = eaddress.Id;
                        contactInforGot.Address.District                    = addressInserted.District;
                        contactInforGot.Address.DistrictId                  = addressInserted.DistrictId;
                        contactInforGot.Address.District.Province           = addressInserted.District.Province;
                        contactInforGot.Address.District.ProvinceId         = addressInserted.District.ProvinceId;
                        contactInforGot.Address.District.Province.Country   = addressInserted.District.Province.Country;
                        contactInforGot.Address.District.Province.CountryId = addressInserted.District.Province.CountryId;
                        contactInformation.IsInUse                          = true;
                        this._contactInformationRepositories.Update(contactInforGot);
                        transactionScope.Complete();
                    }
                    this._iUnitOfWork.Save();
                }
                else // Not found contact information for person
                {
                    ContactInformation contactInformationCreate = new ContactInformation()
                    {
                        Address       = addressInserted,
                        AddressId     = addressInserted.Id,
                        PersonId      = contactInformation.PersonId,
                        ContactForId  = contactInformation.ContactForId,
                        ContactTypeId = contactInformation.ContactTypeId,
                        EAdressId     = eaddress.Id,
                        IsInUse       = true
                    };
                    using (TransactionScope transactionScope = new TransactionScope(TransactionScopeOption.Required))
                    {
                        this._contactInformationRepositories.Add(contactInformationCreate);
                        transactionScope.Complete();
                    }
                    this._iUnitOfWork.Save();
                    var a = this._contactInformationRepositories;
                }
                #endregion
RETURN_HERE:
                {
                    logger.Info(additionalInfo);
                    return(rt);
                };
            }
            catch (Exception e)
            {
                logger.Error("Error: [" + e.Message + "]");
                return(false);
            }
            finally
            {
                logger.LeaveMethod();
            }
        }
    private void SaveMedicalVendor()
    {
        OtherDAL otherDal = new OtherDAL();
        EZip objczip;

        // format phone no.
        CommonCode objCommonCode = new CommonCode();

        objczip = otherDal.CheckCityZip(txtCity.Text, txtZip.Text, ddlState.SelectedValue);

        if (objczip.CityID == 0)
        {
            ClientScript.RegisterStartupScript(typeof(string), "bujscode", "alert('City name entered for contact address is not valid.');", true);
            return;
        }
        else if (objczip.CityID > 0 && objczip.ZipID == 0)
        {
            ClientScript.RegisterStartupScript(typeof(string), "bujscode", "alert('Zip Code entered for contact address, corresponding to its city name, is not valid.');", true);
            return;
        }

        EMVMVUser emvmvUser = new EMVMVUser();
        EMedicalVendor medicalVendor = new EMedicalVendor();

        if (ViewState["AuditRequired"] != null)
            emvmvUser.AuditRequired = Convert.ToBoolean(ViewState["AuditRequired"]);

        medicalVendor.BusinessName = ddlVendorName.SelectedItem.Text;
        if (ViewState["MedicalVendorID"] != null)
        {
            medicalVendor.MedicalVendorID = Convert.ToInt32(ViewState["MedicalVendorID"].ToString());
        }
        else
            medicalVendor.MedicalVendorID = Convert.ToInt32(ddlVendorName.SelectedValue);
        EAddress address = new EAddress();
        address.Address1 = txtAddress1.Text;
        address.Address2 = txtAddress2.Text;
        address.CityID = objczip.CityID;
        address.StateID = Convert.ToInt32(ddlState.SelectedValue);
        address.CountryID = Convert.ToInt32(hfCountryID.Value);
        address.ZipID = objczip.ZipID;

        EUser user = new EUser();
        if (ViewState["UserID"] != null)
        {
            user.UserID = Convert.ToInt32(ViewState["UserID"].ToString());
        }
        user.FirstName = txtFirstName.Text;
        user.MiddleName = txtMiddleName.Text;
        user.LastName = txtLastName.Text;
        user.PhoneCell = objCommonCode.FormatPhoneNumber(txtPhoneC.Text);
        user.PhoneHome = objCommonCode.FormatPhoneNumber(txtPhoneH.Text);
        user.PhoneOffice = objCommonCode.FormatPhoneNumber(txtPhoneO.Text);
        user.DOB = txtDOB.Text;
        user.SSN = txtSSN.Text;
        user.EMail1 = txtEmail1.Text;
        user.EMail2 = txtEmail2.Text;

        user.HomeAddress = address;

        var reference = new EReferences[3];
        reference[0] = new EReferences { Name = string.Empty, EMail = string.Empty };
        reference[1] = new EReferences { Name = string.Empty, EMail = string.Empty };
        reference[2] = new EReferences { Name = string.Empty, EMail = string.Empty };

        EMVUserSpecialization userSpecialization = new EMVUserSpecialization();
        userSpecialization.MVUserSpecilaizationID = Convert.ToInt32(ddlSpecialization.SelectedValue);

        EMVUserClassification emvUserClassification = new EMVUserClassification();
        emvUserClassification.MVUserClassificationID = Convert.ToInt32(ViewState["ClassificationID"]);


        EMVUser emvUser = new EMVUser();
        Ucupdatephotopanel1.GetAllImages();
        emvUser.OtherPictures = Ucupdatephotopanel1.Images;
        emvUser.MyPicture = Ucupdatephotopanel1.MyImage;


        if (ViewState["MVUserID"] != null)
        {
            emvUser.MVUserID = Convert.ToInt32(ViewState["MVUserID"].ToString());
        }
        emvUser.User = user;
        emvUser.References = reference.ToList();
        emvUser.MVUserSpecialization = userSpecialization;
        emvUser.MVUserClassification = emvUserClassification;
        emvUser.Address = address;
        //// For Resume
        string resumePath = ViewState["Resume"].ToString();
        string signPath = ViewState["Signature"].ToString();
        if ((hfResume.Value == "1") && fileResume.HasFile)
        {
            string filePath = Request.MapPath(ConfigurationManager.AppSettings["MVUploadResume"].ToString());
            resumePath = ConfigurationManager.AppSettings["MVUploadResume"].ToString();
            var fileInfo = new FileInfo(fileResume.FileName);
            if (!(fileInfo.Extension.Equals(".doc") || fileInfo.Extension.Equals(".docx") || fileInfo.Extension.Equals(".rtf") || fileInfo.Extension.Equals(".txt")))
            {
                divErrorMsg.Visible = true;
                divErrorMsg.InnerHtml = "Invalid file format. It should be either of type doc, docx, rtf or txt";
                return;
            }
            else
            {
                if (!Directory.Exists(filePath))
                {
                    Directory.CreateDirectory(filePath);
                }
                string saveFileName = fileResume.FileName + DateTime.Now.ToFileTimeUtc() + fileInfo.Extension;
                if (fileResume.HasFile)
                {
                    fileResume.SaveAs(filePath + "\\" + saveFileName);
                }
                resumePath = resumePath + "/" + saveFileName;
            }
        }
        emvUser.Resume = resumePath;
        ////////////////////////signature//////////////////////////////////
        if ((hfSignature.Value == "1") && (fileSignature.FileName.Trim() != ""))
        {
            if (fileSignature.HasFile)
            {
                string signFilePath = Request.MapPath(ConfigurationManager.AppSettings["MVUploadSignature"].ToString());
                signPath = ConfigurationManager.AppSettings["MVUploadSignature"].ToString();

                var fileInfo = new FileInfo(fileSignature.FileName);
                if (!(fileInfo.Extension.ToLower().Equals(".jpeg") || fileInfo.Extension.ToLower().Equals(".jpg")))
                {
                    divErrorMsg.Visible = true;
                    divErrorMsg.InnerHtml = "Please Check the file extension.It should be either of type jpg or jpeg";
                    return;
                }
                else
                {
                    if (!Directory.Exists(signFilePath))
                    {
                        Directory.CreateDirectory(signFilePath);
                    }
                    string saveFileName = fileSignature.FileName.Substring(0, fileSignature.FileName.IndexOf(".")) + DateTime.Now.ToFileTimeUtc() + fileInfo.Extension;
                    if (fileSignature.HasFile)
                    {
                        fileSignature.PostedFile.SaveAs(signFilePath + "\\" + saveFileName);
                    }
                    signPath = signPath + "/" + saveFileName;
                }
            }
        }

        emvUser.DigitalSignature = signPath;
        emvmvUser.MedicalVendor = medicalVendor;

        if (ViewState["IsAuthorizationAllowed"] != null)
            emvmvUser.IsAuthorizationsAllowed = Convert.ToBoolean(ViewState["IsAuthorizationAllowed"]);

        if (ViewState["CutoffDate"] != null)
            emvmvUser.CutOffDate = ViewState["CutoffDate"].ToString();
        if (ViewState["ShowEarningAmount"] != null)
            emvmvUser.ShowEarningAmount = Convert.ToBoolean(ViewState["ShowEarningAmount"]);

        emvmvUser.MVUser = emvUser;

        Int64 returnresult;

        var eUserShellModuleRole = new EUserShellModuleRole
                                                        {
                                                            RoleID = "1",
                                                            ShellID = "1",
                                                            UserID = "1"
                                                        };

        var medicalvendorDal = new MedicalVendorDAL();
        returnresult = medicalvendorDal.SaveMedicalVendorUserProfile(emvmvUser, Convert.ToInt32(EOperationMode.Update), eUserShellModuleRole.UserID, Convert.ToInt64(eUserShellModuleRole.ShellID), eUserShellModuleRole.RoleID);

        if (txtPassword.Text.Length > 0)
        {
            var userLoginService = IoC.Resolve<IUserLoginService>();
            var userContext = IoC.Resolve<SessionContext>();
            userLoginService.ResetPassword(Convert.ToInt32(userContext.UserSession.UserId), txtPassword.Text, false, userContext.UserSession.CurrentOrganizationRole.OrganizationRoleUserId,false);
        }

        Response.RedirectUser(this.ResolveUrl("MedicalVendorUserProfile.aspx"));
    }