Esempio n. 1
0
        protected void CreateUserWizard1_CreatedUser(object sender, EventArgs e)
        {
            string userName = CreateUserWizard1.UserName.ToString();
            string email    = CreateUserWizard1.Email.ToString();

            using (skillsforhireEntities myEntities = new skillsforhireEntities())
            {
                indprofile nwProfile = new indprofile();
                nwProfile.UserName      = userName;
                nwProfile.EmailAddr     = email;
                nwProfile.DateCreated   = DateTime.Now;
                nwProfile.GoldSubExpire = DateTime.Now.AddMonths(6);
                nwProfile.IsGoldMember  = true;
                nwProfile.SortOrder     = 3;
                //Assign Gold Membership
                Roles.AddUserToRole(userName, "Gold");

                //Create new profile and save changes
                myEntities.indprofiles.Add(nwProfile);
                myEntities.SaveChanges();

                //Redirect to profile page
                //Response.Redirect("~/MyProfile.aspx");
            }
        }
Esempio n. 2
0
        protected void btnSendFeedback_Click(object sender, EventArgs e)
        {
            try
            {
                if (Page.IsValid)
                {
                    string pgURL = Request.Url.AbsoluteUri;
                    using (skillsforhireEntities myEntities = new skillsforhireEntities())
                    {
                        jobpostflag myJobFlag = new jobpostflag(); //Create class instance
                        myJobFlag.PostURL          = pgURL;
                        myJobFlag.FlagReason       = tbxFlagReason.Text;
                        myJobFlag.DateTimeReported = DateTime.Now;
                        myJobFlag.ReportedBy       = User.Identity.Name;

                        //Save new item to dbo table
                        myEntities.jobpostflags.Add(myJobFlag);
                        myEntities.SaveChanges();

                        //Provide feedback
                        btnReportLink.Visible      = false;
                        pnlReport.Visible          = false;
                        lblReportFeedback.Text     = "Feedback sent";
                        lblReportFeedback.Visible  = true;
                        lblReportFeedback.CssClass = "text-success";
                    }
                }
            }
            catch
            {
                lblReportFeedback.Text     = "An error has occured. Please try again";
                lblReportFeedback.Visible  = true;
                lblReportFeedback.CssClass = "text-warning";
            }
        }
Esempio n. 3
0
        protected void btnDeleteMultipleRows_Click(object sender, EventArgs e)
        {
            //Loop through all the rows
            foreach (GridViewRow row in GridView1.Rows)
            {
                CheckBox checkbox = (CheckBox)row.FindControl("cbxSelect");
                //Check if the checkbox is checked.
                //value in the HtmlInputCheckBox's Value property is set as the //value of the delete command's parameter.
                if (checkbox.Checked)
                {
                    //Retrieve idJobProfile
                    int JobProfileId = Convert.ToInt32(GridView1.DataKeys[row.RowIndex].Value);
                    // Pass the value of the selected Employye ID to the Delete //command.

                    using (skillsforhireEntities myEntities = new skillsforhireEntities())
                    {
                        var delItem = (from del in myEntities.jobprofiles
                                       where del.idJobProfile == JobProfileId
                                       select del).Single();
                        if (delItem != null)
                        {
                            myEntities.jobprofiles.Remove(delItem);
                            myEntities.SaveChanges();
                        }
                    }
                }
            }
            Response.Redirect("~/Management/AllJobs.aspx");
        }
Esempio n. 4
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            //Get user information
            string         userAccName = User.Identity.Name.ToString();
            MembershipUser user        = Membership.GetUser(userAccName);

            if (Page.IsValid)
            {
                using (skillsforhireEntities myEntities = new skillsforhireEntities())
                {
                    var proUpdate = (from pu in myEntities.indprofiles
                                     where pu.UserName == User.Identity.Name
                                     select pu).Single();

                    //Save to database: update or create new item
                    //Full Name
                    proUpdate.FullName = tbxFullName.Text;
                    //Gender
                    proUpdate.GenderId = Convert.ToInt32(ddlGender.SelectedValue);
                    //Contact Number
                    proUpdate.ContactNo = tbxContactNumb.Text;
                    //Email
                    if (!string.IsNullOrEmpty(tbxEmail.Text))
                    {
                        proUpdate.EmailAddr = tbxEmail.Text;
                    }
                    else
                    {
                        proUpdate.EmailAddr = user.Email;
                    }
                    //State
                    proUpdate.StateId = Convert.ToInt32(ddlState.SelectedValue);
                    //Local Govt
                    proUpdate.LocalGovtId = Convert.ToInt32(ddlLocalGovt.SelectedValue);
                    //Town
                    proUpdate.Town = tbxTown.Text;
                    //Profession
                    proUpdate.SkillsId = Convert.ToInt32(ddlProfession.SelectedValue);
                    //Profession Speciality
                    proUpdate.SkillsSpecific = tbxSpeciality.Text;
                    //Job Experience
                    proUpdate.JobExperience = tbxExperience.Text;
                    //Qualification
                    proUpdate.Qualification = tbxQualification.Text;
                    //Note
                    proUpdate.Note = tbxNote.Text;
                    //Publish
                    proUpdate.Publish = Convert.ToBoolean(cbxPublish.Checked);
                    //Last Modified Date
                    proUpdate.LastModified = DateTime.Now;

                    myEntities.SaveChanges(); //save to database
                    Response.Redirect("~/");
                }
            }
        }
        protected void btnPaymentDetailRequest_Click(object sender, EventArgs e)
        {
            try
            {
                MembershipUser myUser = Membership.GetUser(User.Identity.Name); //Retrieve user information

                //Update BankPaymentRequest database
                using (skillsforhireEntities myEntities = new skillsforhireEntities())
                {
                    bankpaymentrequest addRequest = new bankpaymentrequest();
                    addRequest.userName      = myUser.UserName;
                    addRequest.emailUsed     = myUser.Email;
                    addRequest.paymentType   = "Renew";
                    addRequest.dateRequested = DateTime.Now;

                    myEntities.bankpaymentrequests.Add(addRequest);
                    myEntities.SaveChanges();
                }

                //Send bank detail via e-mail to user
                string fileName = Server.MapPath("~/App_Data/RenewSubPaymentDetails.txt");
                string mailBody = File.ReadAllText(fileName);

                mailBody = mailBody.Replace("##UserName##", myUser.UserName);

                MailMessage myMessage = new MailMessage();
                myMessage.Body    = mailBody;
                myMessage.Subject = "Skills4Hire Bank Payment Details";
                myMessage.From    = new MailAddress(AppConfiguration.FromAccAddress, AppConfiguration.FromName);
                myMessage.To.Add(new MailAddress(myUser.Email));

                SmtpClient mySmtpClient = new SmtpClient();
                mySmtpClient.Send(myMessage);

                //Send feedback
                btnPaymentDetailRequest.Visible = false;
                lblFeedback.Text     = "We have emailed you our bank details. If you cannot find it in your inbox, please check your spam folder";
                lblFeedback.CssClass = "text-success";
                lblFeedback.Visible  = true;
            }
            catch
            {
                lblFeedback.Text     = "An error as occured. Please try again or email us on [email protected]";
                lblFeedback.CssClass = "text-warning";
                lblFeedback.Visible  = true;
            }
        }
Esempio n. 6
0
        //Unpublish expired posts
        protected void unpubExp()
        {
            DateTime useDate = DateTime.Now.Date;

            using (skillsforhireEntities myEntities = new skillsforhireEntities())
            {
                var exp = from k in myEntities.jobprofiles
                          where k.ExpiryDate < useDate
                          select k;
                if (exp != null)
                {
                    foreach (var expItem in exp)
                    {
                        expItem.Publicise = false;
                    }
                    myEntities.SaveChanges();
                }
            }
        }
Esempio n. 7
0
        protected void cbxSave_CheckedChanged(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(Request.QueryString.Get("JobId")))
            {
                if (cbxSave.Checked == true) //SAVE JOB
                {
                    int jobID = Convert.ToInt32(Request.QueryString.Get("JobId"));
                    using (skillsforhireEntities myEntities = new skillsforhireEntities())
                    {
                        var jobItem = (from j in myEntities.jobprofiles
                                       where j.idJobProfile == jobID
                                       select j).SingleOrDefault();
                        if (jobItem != null)
                        {
                            mysavedjob toSaveJob = new mysavedjob();
                            toSaveJob.sJobId    = jobID;
                            toSaveJob.sJobTitle = jobItem.JobTitle;
                            toSaveJob.DateSaved = DateTime.Now.Date;
                            toSaveJob.SavedBy   = User.Identity.Name;

                            myEntities.mysavedjobs.Add(toSaveJob);
                            myEntities.SaveChanges();
                        }
                    }
                }
                else //DELETE SAVED JOB
                {
                    int jobID = Convert.ToInt32(Request.QueryString.Get("JobId"));
                    using (skillsforhireEntities myEntities = new skillsforhireEntities())
                    {
                        var mySavedJob = (from s in myEntities.mysavedjobs
                                          where (s.sJobId == jobID && s.SavedBy == User.Identity.Name)
                                          select s).SingleOrDefault();
                        if (mySavedJob != null)
                        {
                            myEntities.mysavedjobs.Remove(mySavedJob);
                            myEntities.SaveChanges();
                        }
                    }
                }
            }
        }
Esempio n. 8
0
        //Delete expired posts
        protected void delExp()
        {
            Double   delBeyond = Convert.ToDouble(ddlDeleteBeyond.SelectedValue);
            DateTime useDate   = DateTime.Now.AddDays(delBeyond).Date;

            using (skillsforhireEntities myEntities = new skillsforhireEntities())
            {
                var del = from E in myEntities.jobprofiles
                          where E.ExpiryDate < useDate
                          select E;
                if (del != null)
                {
                    foreach (var iDel in del)
                    {
                        myEntities.jobprofiles.Remove(iDel);
                    }
                }
                myEntities.SaveChanges();
            }
        }
Esempio n. 9
0
        protected void btnPost_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                using (skillsforhireEntities myEntities = new skillsforhireEntities())
                {
                    jobprofile myJobProfile;
                    if (_id == -1) //Create new profile
                    {
                        myJobProfile                = new jobprofile();
                        myJobProfile.CreatedBy      = User.Identity.Name;
                        myJobProfile.DateCreated    = DateTime.Now;
                        myJobProfile.LastModified   = myJobProfile.DateCreated;
                        myJobProfile.LastModifiedBy = User.Identity.Name;
                        myEntities.jobprofiles.Add(myJobProfile);
                    }
                    else
                    {
                        myJobProfile = (from P in myEntities.jobprofiles
                                        where P.idJobProfile == _id
                                        select P).Single();
                        myJobProfile.LastModified   = DateTime.Now;
                        myJobProfile.LastModifiedBy = User.Identity.Name;
                    }
                    //Job Status
                    myJobProfile.JobStatusId = Convert.ToInt32(ddlJobStatus.SelectedValue);
                    //Start Time
                    myJobProfile.StartTimeId = Convert.ToInt32(ddlStartTime.SelectedValue);
                    //Job loc. state
                    myJobProfile.JobLocationStateId = Convert.ToInt32(ddlJobLocState.SelectedValue);
                    //Job loc. LG
                    myJobProfile.JobLocationLGId = Convert.ToInt32(ddlJobLocLG.SelectedValue);
                    //Job loc. town
                    if (tbxJobLocTown.Text != "")
                    {
                        myJobProfile.JobLocationTown = tbxJobLocTown.Text;
                    }
                    else
                    {
                        myJobProfile.JobLocationTown = "-";
                    }
                    //Job title
                    myJobProfile.JobTitle = tbxJobTitle.Text;
                    //Job description
                    myJobProfile.JobDescription = tbxJobDescription.Text;
                    //Profession
                    myJobProfile.SkillId = Convert.ToInt32(ddlSkill.SelectedValue);
                    //Specialisation
                    if (tbxSkillSpecific.Text != "")
                    {
                        myJobProfile.SpecificSkill = tbxSkillSpecific.Text;
                    }
                    else
                    {
                        myJobProfile.SpecificSkill = "-";
                    }
                    //Budget
                    myJobProfile.BudgetId = Convert.ToInt32(ddlBudget.SelectedValue);
                    //Full Name
                    myJobProfile.ContactFullName = tbxFullName.Text;
                    //Contact Number
                    myJobProfile.ContactNumber = tbxContactNumb.Text;
                    //Email
                    myJobProfile.ContactEmail = tbxEmail.Text;
                    //Publicise
                    myJobProfile.Publicise = Convert.ToBoolean(cbxPublicise.Checked);
                    //Expiry Date
                    myJobProfile.ExpiryDate = DateTime.Today.AddDays(Convert.ToDouble(ddlAdvertDuration.SelectedValue));

                    //save changes
                    myEntities.SaveChanges();
                    Response.Redirect("~/");
                }
            }
        }
Esempio n. 10
0
        protected void btnAccDelConfirmation_Click(object sender, EventArgs e)
        {
            string         userAccName = User.Identity.Name.ToString();
            MembershipUser user        = Membership.GetUser(userAccName);

            //clean-up profile
            using (skillsforhireEntities myObjects = new skillsforhireEntities())
            {
                var ind = (from i in myObjects.indprofiles
                           where i.UserName == userAccName
                           select i).Single();
                if (ind != null)
                {
                    myObjects.indprofiles.Remove(ind);
                }
                myObjects.SaveChanges();
            }
            //clean-up posted jobs
            using (skillsforhireEntities myEntities = new skillsforhireEntities())
            {
                var jobPosts = from p in myEntities.jobprofiles
                               where p.CreatedBy == userAccName
                               select p;
                if (jobPosts != null)
                {
                    foreach (var jPost in jobPosts)
                    {
                        myEntities.jobprofiles.Remove(jPost);
                    }
                    myEntities.SaveChanges();
                }
            }
            //update deletedMembership table
            using (skillsforhireEntities myContext = new skillsforhireEntities())
            {
                deletedmembership delMemb = new deletedmembership();
                delMemb.userName      = user.UserName;
                delMemb.email         = user.Email;
                delMemb.leavingReason = tbxAccDelReason.Text;
                delMemb.Date          = DateTime.Now;
                //Save to database
                myContext.deletedmemberships.Add(delMemb);
                myContext.SaveChanges();
            }
            //send confirmation email
            string fileName = Server.MapPath("~/App_Data/AccountDeleteConfirmation.txt");
            string mailBody = File.ReadAllText(fileName);

            mailBody = mailBody.Replace("##UserName##", user.UserName);

            MailMessage myMessage = new MailMessage();

            myMessage.Subject = "Your www.skills4hire.com.ng Account is Deleted";
            myMessage.Body    = mailBody;

            myMessage.From = new MailAddress(AppConfiguration.FromAccAddress, "Accounts");
            myMessage.To.Add(new MailAddress(user.Email));

            SmtpClient mySmtpClient = new SmtpClient();

            mySmtpClient.Send(myMessage);

            //Delete account
            Membership.DeleteUser(userAccName);
            //programatically logout acccount and redirect to homepage
            FormsAuthentication.SignOut();
            Response.Redirect("~/");
        }