public ActionResult Get(int id) { IMailAdressService mailAdressService = InstanceFactory.GetInstance<IMailAdressService>(); MailAdress mailAdress = mailAdressService.Get(id); return Ok(mailAdress); }
public ActionResult Delete(int id) { try { IMailAdressService mailAdressService = InstanceFactory.GetInstance<IMailAdressService>(); MailAdress mailAdress = mailAdressService.Get(id); if (mailAdress!=null) { mailAdressService.Delete(mailAdress); return Ok(); } else { return BadRequest("İlgili Mail Adresi Bulunamadı yada Silinmiş."); } } catch (Exception e) { return BadRequest(e.Message); } }
public ActionResult Post(SendMailModel model) { try { IMailAdressService mailAdressService = InstanceFactory.GetInstance <IMailAdressService>(); MailAdress mailAdress = mailAdressService.Get(model.MailAdressID); if (mailAdress != null) { SendMail sendMail = new SendMail(); string displayname = mailAdress.DisplayName; string subject = model.MovieName + " Filminiz Mutlaka İzleyin"; string userName = mailAdress.Username; string server = mailAdress.Server; string password = mailAdress.Password; int port = mailAdress.Port; bool ssl = mailAdress.SSL; string content = model.Mail + " adresine sahip kullanıcı size " + model.MovieName + " adlı filmi izleminizi tavsiye ediyor."; List <string> list = new List <string>(); list.Add(model.Mail); string result = sendMail.Send(subject, content, list, userName, password, server, port, displayname, ssl) ? "Mail Gönderildi" : "Mail Gönderilemedi"; return(Ok(result)); } else { return(BadRequest()); } } catch (Exception e) { return(BadRequest(e.Message)); } }