Exemplo n.º 1
0
        // PUT api/Email/5
        public IHttpActionResult PutEmailCorrespondence(int id, EmailCorrespondence emailcorrespondence)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            if (id != emailcorrespondence.Reg_ID)
            {
                return BadRequest();
            }

            db.Entry(emailcorrespondence).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!EmailCorrespondenceExists(id))
                {
                    return NotFound();
                }
                else
                {
                    throw;
                }
            }

            return StatusCode(HttpStatusCode.NoContent);
        }
Exemplo n.º 2
0
 public string GetEmailCorrespondence(string query, string para1,string para2, string para3, string para4,string para5)
 {
     if (query == "sendemail")
     {
         var row = from m in db.Event_Symposium_Email_Template
                   where m.Name == "submission"
                   select new { m.EmailFrom, m.EmailFromName, m.EmailCc, m.EmailBcc, m.EmailSubject, m.EmailBody };
         foreach (var c in row)
         {
             var emailbody = c.EmailBody;
             StringBuilder builder = new StringBuilder(emailbody);
             builder.Replace("[[StudentFirstName]]", para2).Replace("[[StudentLastName]]", para3);
             string emailBody = builder.ToString();
             SendEmail(c.EmailFrom, c.EmailFromName, para1, c.EmailCc, "", c.EmailSubject, emailBody, false); // c.EmailBcc
             return "emailsent";
         }
           return "emailsent";
     }
     else if (query == "sendemail1")
     {
         var row = from m in db.Event_Symposium_Email_Template
                   where m.Name == "applicationapproved"
                   select new { m.EmailFrom, m.EmailFromName, m.EmailCc, m.EmailBcc, m.EmailSubject, m.EmailBody };
         foreach (var c in row)
         {
             var emailbody = c.EmailBody;
             StringBuilder builder = new StringBuilder(emailbody);
             builder.Replace("[[StudentFirstName]]", para2).Replace("[[StudentLastName]]", para3).Replace("[[ApplicationTitle]]", para4);
             string emailBody = builder.ToString();
             SendEmail(c.EmailFrom, c.EmailFromName, para1, c.EmailCc, "", c.EmailSubject, emailBody, false); // c.EmailBcc
             return "emailsent1";
         }
     }
     else if (query == "sendemail2")
     {
         var row = from m in db.Event_Symposium_Email_Template
                   where m.Name == "applicationdeclined"
                   select new { m.EmailFrom, m.EmailFromName, m.EmailCc, m.EmailBcc, m.EmailSubject, m.EmailBody };
         foreach (var c in row)
         {
             var emailbody = c.EmailBody;
             StringBuilder builder = new StringBuilder(emailbody);
             builder.Replace("[[StudentFirstName]]", para2).Replace("[[StudentLastName]]", para3).Replace("[[ApplicationTitle]]", para4); ;
             string emailBody = builder.ToString();
             SendEmail(c.EmailFrom, c.EmailFromName, para1, c.EmailCc, "", c.EmailSubject, emailBody, false); // c.EmailBcc
             return "emailsent2";
         }
     }
     else if (query == "insertrecord")
     {
         EmailCorrespondence temp=new EmailCorrespondence();
         temp.Ev_ID = Convert.ToInt32(para1);
         temp.Reg_ID = Convert.ToInt32(para2);
         temp.EmailTo = para3;
         temp.EmailBcc = "[email protected];[email protected]";
         temp.EmailSubject = "Annenberg Symposium Abstract Submission Confirmation";
         temp.EmailBody = para4;
         temp.dtDate =  DateTime.Parse(para5);
         PostEmailCorrespondence(temp);
         return "recordinserted";
     }
     return "unsolved";
 }
Exemplo n.º 3
0
        public IHttpActionResult PostEmailCorrespondence(EmailCorrespondence emailcorrespondence)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            db.EmailCorrespondences.Add(emailcorrespondence);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateException)
            {
                if (EmailCorrespondenceExists(emailcorrespondence.Reg_ID))
                {
                    return Conflict();
                }
                else
                {
                    throw;
                }
            }

            return CreatedAtRoute("DefaultApi", new { id = emailcorrespondence.Reg_ID }, emailcorrespondence);
        }