Ejemplo n.º 1
0
 protected void removeUsersInRole()
 {
     foreach (ListItem li in lbxUsersInRole.Items)
     {
         if (li.Selected == true)
         {
             //Update indProfile table
             string userName = li.Text;
             using (skillsforhireEntities myEntities = new skillsforhireEntities())
             {
                 var getUser = (from u in myEntities.indprofiles
                                where u.UserName == userName
                                select u).Single();
                 if (getUser != null)
                 {
                     getUser.IsGoldMember = false;
                 }
                 myEntities.SaveChanges();
             }
             //Update membership table
             Roles.RemoveUserFromRole(li.ToString(), ddlAllRoles.SelectedItem.Text);
         }
     }
 }
Ejemplo n.º 2
0
        protected void btnSend_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                try
                {
                    //All Users Email
                    if (ddlToGroup.SelectedValue == "1")
                    {
                        using (skillsforhireEntities myEntities = new skillsforhireEntities())
                        {
                            var allEmails = from u in myEntities.indprofiles
                                            select u.EmailAddr;
                            if (allEmails != null)
                            {
                                foreach (var itm in allEmails)
                                {
                                    //send email
                                    MailMessage myMessage = new MailMessage();
                                    myMessage.To.Add(new MailAddress(itm.ToString()));
                                    myMessage.From    = new MailAddress(AppConfiguration.FromNoreplyAddress, AppConfiguration.FromName);
                                    myMessage.Subject = tbxSubject.Text;
                                    myMessage.Body    = tbxBody.Text;

                                    SmtpClient mySmtpClient = new SmtpClient();
                                    mySmtpClient.Send(myMessage);
                                }
                            }
                        }
                    }
                    //New Users < 1month Email
                    else if (ddlToGroup.SelectedValue == "2")
                    {
                        DateTime dateCreated = DateTime.Now.AddDays(-30);
                        using (skillsforhireEntities myEntities = new skillsforhireEntities())
                        {
                            var allEmails = from u in myEntities.indprofiles
                                            where u.DateCreated > dateCreated
                                            select u.EmailAddr;
                            if (allEmails != null)
                            {
                                foreach (var itm in allEmails)
                                {
                                    //send email
                                    MailMessage myMessage = new MailMessage();
                                    myMessage.To.Add(new MailAddress(itm.ToString()));
                                    myMessage.From    = new MailAddress(AppConfiguration.FromNoreplyAddress, AppConfiguration.FromName);
                                    myMessage.Subject = tbxSubject.Text;
                                    myMessage.Body    = tbxBody.Text;

                                    SmtpClient mySmtpClient = new SmtpClient();
                                    mySmtpClient.Send(myMessage);
                                }
                            }
                        }
                    }
                    //Expired Gold Users Email
                    else if (ddlToGroup.SelectedValue == "3")
                    {
                        using (skillsforhireEntities myEntities = new skillsforhireEntities())
                        {
                            var allEmails = from u in myEntities.indprofiles
                                            where u.GoldSubExpire < DateTime.Now
                                            select u.EmailAddr;
                            if (allEmails != null)
                            {
                                foreach (var itm in allEmails)
                                {
                                    //send email
                                    MailMessage myMessage = new MailMessage();
                                    myMessage.To.Add(new MailAddress(itm.ToString()));
                                    myMessage.From    = new MailAddress(AppConfiguration.FromNoreplyAddress, AppConfiguration.FromName);
                                    myMessage.Subject = tbxSubject.Text;
                                    myMessage.Body    = tbxBody.Text;

                                    SmtpClient mySmtpClient = new SmtpClient();
                                    mySmtpClient.Send(myMessage);
                                }
                            }
                        }
                    }
                    // seleted no skill/profession
                    else if (ddlToGroup.SelectedValue == "4")
                    {
                        using (skillsforhireEntities myEntities = new skillsforhireEntities())
                        {
                            var allEmails = from u in myEntities.indprofiles
                                            where u.SkillsId == 78
                                            select u.EmailAddr;
                            if (allEmails != null)
                            {
                                foreach (var itm in allEmails)
                                {
                                    //send email
                                    MailMessage myMessage = new MailMessage();
                                    myMessage.To.Add(new MailAddress(itm.ToString()));
                                    myMessage.From    = new MailAddress(AppConfiguration.FromNoreplyAddress, AppConfiguration.FromName);
                                    myMessage.Subject = tbxSubject.Text;
                                    myMessage.Body    = tbxBody.Text;

                                    SmtpClient mySmtpClient = new SmtpClient();
                                    mySmtpClient.Send(myMessage);
                                }
                            }
                        }
                    }
                    pnlSendMessage.Visible   = false;
                    lblSendFeedback.Visible  = true;
                    lblSendFeedback.Text     = "Message sent";
                    lblSendFeedback.CssClass = "text-success";
                }
                catch
                {
                    pnlSendMessage.Visible   = false;
                    lblSendFeedback.Visible  = true;
                    lblSendFeedback.Text     = "Sending message failed";
                    lblSendFeedback.CssClass = "text-warning";
                }
            }
        }
Ejemplo n.º 3
0
        protected void btnPost_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                using (skillsforhireEntities myEntities = new skillsforhireEntities())
                {
                    int        id = Convert.ToInt32(Request.QueryString.Get("JobId"));
                    jobprofile myJobProfile;

                    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("~/Management/AllJobs.aspx");
                }
            }
        }
Ejemplo n.º 4
0
        //int _id = -1; //to distinguish between a new and existing post
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack && !string.IsNullOrEmpty(Request.QueryString.Get("JobId")))
            {
                int id = Convert.ToInt32(Request.QueryString.Get("JobId"));
                using (skillsforhireEntities myEntities = new skillsforhireEntities())
                {
                    var jobAd = (from j in myEntities.jobprofiles
                                 where j.idJobProfile == id
                                 select j).SingleOrDefault();
                    if (jobAd != null)
                    {
                        //Get job status
                        ddlJobStatus.DataBind();
                        ListItem myddlJobStatus = ddlJobStatus.Items.FindByValue(jobAd.JobStatusId.ToString());
                        if (myddlJobStatus != null)
                        {
                            myddlJobStatus.Selected = true;
                        }
                        //Start Time
                        ddlStartTime.DataBind();
                        ListItem myddlStartTime = ddlStartTime.Items.FindByValue(jobAd.StartTimeId.ToString());
                        if (myddlStartTime != null)
                        {
                            myddlStartTime.Selected = true;
                        }
                        //Job loc. state
                        ddlJobLocState.DataBind();
                        ListItem myddlState = ddlJobLocState.Items.FindByValue(jobAd.JobLocationStateId.ToString());
                        if (myddlState != null)
                        {
                            myddlState.Selected = true;
                        }
                        //Job loc. LG
                        ddlJobLocLG.DataBind();
                        ListItem myddlLG = ddlJobLocLG.Items.FindByValue(jobAd.JobLocationLGId.ToString());
                        if (myddlLG != null)
                        {
                            myddlLG.Selected = true;
                        }
                        //Job loc. town
                        tbxJobLocTown.Text = jobAd.JobLocationTown.ToString();
                        //Job title
                        tbxJobTitle.Text = jobAd.JobTitle.ToString();
                        //Job description
                        tbxJobDescription.Text = jobAd.JobDescription;
                        //Profession
                        ddlSkill.DataBind();
                        ListItem myddlSkill = ddlSkill.Items.FindByValue(jobAd.SkillId.ToString());
                        if (myddlSkill != null)
                        {
                            myddlSkill.Selected = true;
                        }
                        //Specialisation
                        tbxSkillSpecific.Text = jobAd.SpecificSkill.ToString();
                        //Budget
                        ddlBudget.DataBind();
                        ListItem myddlBudget = ddlBudget.Items.FindByValue(jobAd.BudgetId.ToString());
                        if (myddlBudget != null)
                        {
                            myddlBudget.Selected = true;
                        }
                        //Full Name
                        tbxFullName.Text = jobAd.ContactFullName;

                        //Contact Number
                        tbxContactNumb.Text = jobAd.ContactNumber;
                        //Email
                        tbxEmail.Text = jobAd.ContactEmail;
                        //Expiry Date

                        //Publicise
                        cbxPublicise.Checked = Convert.ToBoolean(jobAd.Publicise);
                    }
                }
            }
        }
Ejemplo n.º 5
0
        protected void btnDelMembership_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                if (Membership.GetUser(tbxUserName.Text) != null)
                {
                    string userName = tbxUserName.Text;
                    //Delete Job Postings
                    using (skillsforhireEntities myEntities = new skillsforhireEntities())
                    {
                        var jobPosts = from p in myEntities.jobprofiles
                                       where p.CreatedBy == userName
                                       select p;
                        if (jobPosts != null)
                        {
                            foreach (var jPost in jobPosts)
                            {
                                myEntities.jobprofiles.Remove(jPost);
                            }
                            myEntities.SaveChanges();
                        }
                    }

                    //Delete Profile
                    using (skillsforhireEntities myObjects = new skillsforhireEntities())
                    {
                        var ind = (from i in myObjects.indprofiles
                                   where i.UserName == userName
                                   select i).SingleOrDefault();
                        if (ind != null)
                        {
                            //send confirmation email
                            string fileName = Server.MapPath("~/App_Data/AccountDeleteConfirmation.txt");
                            string mailBody = File.ReadAllText(fileName);

                            mailBody = mailBody.Replace("##UserName##", ind.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(ind.EmailAddr));

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

                            //Remove user profile
                            myObjects.indprofiles.Remove(ind);
                        }
                        myObjects.SaveChanges();
                    }

                    //Delete user
                    Membership.DeleteUser(userName);
                    lblUserFeed.Text = "User Account deleted!";
                }
                else
                {
                    lblUserFeed.Text = "User Name not found";
                }
            }
        }