Beispiel #1
0
        protected void btnPublish_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 GuarJobId = Convert.ToInt32(GridView1.DataKeys[row.RowIndex].Value);
                    // Pass the value of the selected JobProfileId to the Delete //command.

                    using (skillsforhireEntities myEntities = new skillsforhireEntities())
                    {
                        var PubItem = (from itm in myEntities.guardianjobs
                                       where itm.Id == GuarJobId
                                       select itm).Single();
                        if (PubItem != null && PubItem.Publish == false)
                        {
                            PubItem.Publish        = true;
                            PubItem.EditedBy       = User.Identity.Name;
                            PubItem.DateTimeEdited = DateTime.Now;
                            myEntities.SaveChanges();
                        }
                    }
                }
            }
            Response.Redirect("~/Management/BulkManageGuardianJobs.aspx");
        }
Beispiel #2
0
        protected void btnDel_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 GuarJobId = Convert.ToInt32(GridView1.DataKeys[row.RowIndex].Value);
                    // Pass the value of the selected JobProfileId to the Delete //command.

                    using (skillsforhireEntities myEntities = new skillsforhireEntities())
                    {
                        var delItem = (from del in myEntities.guardianjobs
                                       where del.Id == GuarJobId
                                       select del).Single();
                        if (delItem != null)
                        {
                            myEntities.guardianjobs.Remove(delItem);
                            myEntities.SaveChanges();
                        }
                    }
                }
            }
            Response.Redirect("~/Management/BulkManageGuardianJobs.aspx");
        }
Beispiel #3
0
 protected void btnUpgrade_Click(object sender, EventArgs e)
 {
     try
     {
         using (skillsforhireEntities myEntities = new skillsforhireEntities())
         {
             var renewGold = from nw in myEntities.indprofiles
                             where (nw.GoldSubExpire > DateTime.Now && nw.IsGoldMember == false)
                             select nw;
             if (renewGold != null)
             {
                 foreach (var renewItem in renewGold)
                 {
                     //Check IsGoldMember property
                     renewItem.IsGoldMember = true;
                     //Upgrade to Gold membership
                     Roles.AddUserToRole(renewItem.UserName, "Gold");
                 }
                 myEntities.SaveChanges();
             }
         }
         Response.Redirect("~/Management/UserRoles.aspx");
     }
     catch
     {
         lblUpgradeFeedback.Text = "An error has occured. Refresh the page and try again";
     }
 }
        protected void btnDelMembership_Click(object sender, EventArgs e)
        {
            lblUserFeed.Text = "";
            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.Any())
                        {
                            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;
                        if (ind.Any())
                        {
                            foreach (var itm in ind)
                            {
                                //remove indProfile
                                myObjects.indprofiles.Remove(itm);
                            }
                            myObjects.SaveChanges();
                        }

                        //else
                        //{
                        //    lblUserFeed.Text = "User Name not found";
                        //}
                    }

                    //Delete Account
                    //Delete user
                    Membership.DeleteUser(userName);
                    lblUserFeed.Text = "User Account deleted!";
                }
            }
        }
Beispiel #5
0
        protected void btnUpdateAllUsers_Click(object sender, EventArgs e)
        {
            clrLabel(); //clear labels
            lblAllUsersFeedback.Text = "";
            if (ddlAllUsers.SelectedValue != "0" && ddlExpiryRange.SelectedValue != "-- Select Expiry Duration --")
            {
                //Months to be given
                int      myMonths  = Convert.ToInt32(ddlAllUsers.SelectedValue);
                DateTime addMonths = DateTime.Now.AddMonths(myMonths);

                //Filter people to give addional membership
                int      timeRangeVal = Convert.ToInt32(ddlExpiryRange.SelectedValue);
                DateTime timeMark     = DateTime.Now.AddMonths(timeRangeVal);

                using (skillsforhireEntities myEntities = new skillsforhireEntities())
                {
                    var AllUsers = from u in myEntities.indprofiles
                                   where u.GoldSubExpire < timeMark
                                   select u;
                    foreach (var itm in AllUsers)
                    {
                        //Extend Gold membership
                        itm.GoldSubExpire = addMonths;

                        //Send email notification of renewed Gold membership

                        string fileName = Server.MapPath("~/App_Data/ExtendGoldMembership.txt");
                        string mailBody = File.ReadAllText(fileName);

                        mailBody = mailBody.Replace("##Time##", myMonths.ToString());

                        MailMessage myMailMessage = new MailMessage();
                        myMailMessage.Body    = mailBody;
                        myMailMessage.Subject = "We have Extended Your Gold Membership Subscription";
                        myMailMessage.To.Add(new MailAddress(itm.EmailAddr));
                        myMailMessage.From = new MailAddress(AppConfiguration.FromAccAddress, AppConfiguration.FromName);

                        SmtpClient mySmtpClient = new SmtpClient();
                        mySmtpClient.Send(myMailMessage);
                    }
                    myEntities.SaveChanges();
                    lblAllUsersFeedback.Text = "Completed";
                }
            }
            else
            {
                lblAllUsersFeedback.Text = "Select Months to Give and Expiry Time Range";
            }
        }
Beispiel #6
0
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            int id = Convert.ToInt32(Request.QueryString.Get("JobId"));

            using (skillsforhireEntities myEntities = new skillsforhireEntities())
            {
                var delPost = (from del in myEntities.jobprofiles
                               where del.idJobProfile == id
                               select del).Single();
                if (delPost != null)
                {
                    myEntities.jobprofiles.Remove(delPost);
                    myEntities.SaveChanges();
                }
            }
            Response.Redirect("~/Management/AllJobs.aspx");
        }
 protected void btnUnpublish_Click(object sender, EventArgs e)
 {
     //Unpublish all users without professional profile
     using (skillsforhireEntities myEntities = new skillsforhireEntities())
     {
         var allItms = from a in myEntities.indprofiles
                       where a.SkillsId == 78 && a.Publish == true
                       select a;
         if (allItms.Any())
         {
             foreach (var itm in allItms)
             {
                 itm.Publish = false;
             }
             myEntities.SaveChanges();
         }
     }
     Response.Redirect("~/Management/ManageUserSortOrder.aspx");
 }
 protected void btnUpgrade_Click(object sender, EventArgs e)
 {
     //Upgrade all users with updated professional profile
     using (skillsforhireEntities myEntities = new skillsforhireEntities())
     {
         var allItms = from a in myEntities.indprofiles
                       where a.SkillsId != 78 && a.SortOrder == 4
                       select a;
         if (allItms.Any())
         {
             foreach (var itm in allItms)
             {
                 itm.SortOrder = 3;
             }
             myEntities.SaveChanges();
         }
     }
     //countUpgrades();
     Response.Redirect("~/Management/ManageUserSortOrder.aspx");
 }
Beispiel #9
0
        protected void btnDowngrade_Click(object sender, EventArgs e)
        {
            try
            {
                using (skillsforhireEntities myEntities = new skillsforhireEntities())
                {
                    var expGold = from ex in myEntities.indprofiles
                                  where (ex.GoldSubExpire < DateTime.Now && ex.IsGoldMember == true)
                                  select ex;
                    if (expGold != null)
                    {
                        foreach (var exItm in expGold)
                        {
                            //Uncheck IsGoldMember
                            exItm.IsGoldMember = false;
                            //Remove membership
                            Roles.RemoveUserFromRole(exItm.UserName, "Gold");

                            //Send email advise
                            string fileName = Server.MapPath("~/App_Data/ExpiredGoldMembership.txt");
                            string mailBody = File.ReadAllText(fileName);

                            MailMessage myMessage = new MailMessage();
                            myMessage.Body    = mailBody;
                            myMessage.Subject = "We have Extended Your Gold Membership Subscription";
                            myMessage.To.Add(new MailAddress(exItm.EmailAddr));
                            myMessage.From = new MailAddress(AppConfiguration.FromAccAddress, AppConfiguration.FromName);

                            SmtpClient mySmtpClient = new SmtpClient();
                            mySmtpClient.Send(myMessage);
                        }
                        myEntities.SaveChanges();
                    }
                }
                Response.Redirect("~/Management/UserRoles.aspx");
            }
            catch
            {
                lblDowngradeFeedback.Text = "An error has occured. Refresh the page and try again";
            }
        }
Beispiel #10
0
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            //Bulk delete jobs > 8 weeks
            DateTime timePoint = DateTime.Now.AddMonths(-3);

            using (skillsforhireEntities myEntities = new skillsforhireEntities())
            {
                var getItms = from i in myEntities.guardianjobs
                              where i.PublicationDate < timePoint
                              select i;
                if (getItms.Any())
                {
                    foreach (var itm in getItms)
                    {
                        myEntities.guardianjobs.Remove(itm);
                    }
                    myEntities.SaveChanges();
                }
            }
            Response.Redirect("~/Management/BulkManageGuardianJobs.aspx");
        }
Beispiel #11
0
        protected void btnUnpublish_Click(object sender, EventArgs e)
        {
            //Bulk unpublish jobs > 8 weeks
            DateTime timePoint = DateTime.Now.AddMonths(-2);

            using (skillsforhireEntities myEntities = new skillsforhireEntities())
            {
                var getItms = from i in myEntities.guardianjobs
                              where i.PublicationDate < timePoint && i.Publish == true
                              select i;
                if (getItms.Any())
                {
                    foreach (var itm in getItms)
                    {
                        itm.Publish        = false;
                        itm.EditedBy       = User.Identity.Name;
                        itm.DateTimeEdited = DateTime.Now;
                    }
                    myEntities.SaveChanges();
                }
            }
            Response.Redirect("~/Management/BulkManageGuardianJobs.aspx");
        }
Beispiel #12
0
        protected void btnUpdateAUser_Click(object sender, EventArgs e)
        {
            clrLabel(); //clear labels
            try
            {
                if (!string.IsNullOrEmpty(tbxUserName.Text) && !string.IsNullOrEmpty(tbxNewExpDate.Text))
                {
                    DateTime nwexpDate = Convert.ToDateTime(tbxNewExpDate.Text);
                    string   uName     = tbxUserName.Text;

                    using (skillsforhireEntities myEntities = new skillsforhireEntities())
                    {
                        var fdUser = (from k in myEntities.indprofiles
                                      where k.UserName == uName
                                      select k).Single();
                        if (fdUser != null)
                        {
                            fdUser.GoldSubExpire = nwexpDate;
                            myEntities.SaveChanges();
                            lblGoldUpdateInfo.Text = "Update was successful";
                        }
                        else
                        {
                            lblGoldUpdateInfo.Text = "No user information was found";
                        }
                    }
                }
                else
                {
                    lblGoldUpdateInfo.Text = "User Name and New Expiry Date fields cannot be left empty";
                }
            }
            catch
            {
                lblGoldUpdateInfo.Text = "An error has occured. Please confirm the values entered";
            }
        }
Beispiel #13
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);
         }
     }
 }
        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");
                }
            }
        }
        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";
                }
            }
        }