public ActionResult <Request> CreateRequest(Request createRequest) { _repository.CreateRequest(createRequest); _repository.SaveChanges(); //send mail var fromAddress = new MailAddress("fromAddress", "My Name"); var toAddress = new MailAddress("toAdress", "Mr Test"); const string fromPassword = "******"; const string subject = "Request"; const string body = "Request Created!"; var smtp = new SmtpClient { Host = "smtp.gmail.com", Port = 587, EnableSsl = true, DeliveryMethod = SmtpDeliveryMethod.Network, UseDefaultCredentials = false, Credentials = new NetworkCredential(fromAddress.Address, fromPassword), Timeout = 20000 }; using (var message = new MailMessage(fromAddress, toAddress) { Subject = subject, Body = body }) { smtp.Send(message); } return(createRequest); }
public ActionResult <Request> CreateRequest(Request createRequest) { SRMContext context = new SRMContext(); _repository.CreateRequest(createRequest); context.SaveChanges(); return(createRequest); }