コード例 #1
0
 // The id parameter name should match the DataKeyNames value set on the control
 public void gvJobPostings_DeleteItem(Posting posting)
 {
     using (var context = new CareersContext())
     {
         context.Entry(posting).State = System.Data.Entity.EntityState.Deleted;
         context.SaveChanges();
     }
 }
コード例 #2
0
        private void SendUnapprovedNotification(Posting posting)
        {
            if (ConfigurationManager.AppSettings["SendCareersNotifications"] != null && bool.Parse(ConfigurationManager.AppSettings["SendCareersNotifications"]))
            {
                try
                {
                    //todo set up mail correctly
                    MailMessage mailMessage = new MailMessage();
                    mailMessage.To.Add(ConfigurationManager.AppSettings["CareersToEmail"]);
                    mailMessage.From = new MailAddress(ConfigurationManager.AppSettings["CareersFromEmail"]);
                    mailMessage.Subject = "Job Posting " + posting.JobID + " Needs to be approved";
                    mailMessage.Body = "Job Posting " + posting.JobID + " Needs to be approved <br /><br /> " + HttpContext.Current.Request.Url.AbsoluteUri;
                    mailMessage.IsBodyHtml = true;

                    SmtpClient smtpClient = new SmtpClient(ConfigurationManager.AppSettings["CareersSmtpClient"]);
                    smtpClient.Send(mailMessage);
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
        }
コード例 #3
0
        public void fvJobPosting_UpdateItem(Posting posting)
        {
            if (((bool)(Session["ChangeToEditMode"] ?? false) || (bool)(Session["ChangeToViewMode"] ?? false)))
            {
                Session["Posting"] = posting;
            }
            else
            {
                UpdatePosting(posting);

            }
        }
コード例 #4
0
        private void UpdatePosting(Posting posting)
        {
            using (var context = new CareersContext())
            {
                if (posting.JobID == 0 && !IsStaffUser && PostingCredits <= 0) Response.Redirect(Request.Url.AbsoluteUri);
                bool decrementJobCredits = false;
                var postDateString = string.Empty;
                DateTime postDate;
                var postDateTextbox = (TextBox)fvJobPosting.FindControl("txtPostDate");
                if (postDateTextbox.Text != null && DateTime.TryParse(postDateTextbox.Text, out postDate)) posting.PostDate = postDate;
                else posting.PostDate = null;
                if (posting.JobID == 0)
                {
                    context.Entry(posting).State = System.Data.Entity.EntityState.Added;
                    if (!IsStaffUser) decrementJobCredits = true;
                }
                else context.Entry(posting).State = System.Data.Entity.EntityState.Modified;
                if (posting.Approved == false) SendUnapprovedNotification(posting);
                context.SaveChanges();
                if (decrementJobCredits) PostingCredits = PostingCredits - 1;

            }
            Response.Redirect(Request.Url.AbsolutePath + "?PostingId=" + posting.JobID.ToString());
        }