public void IHaveThisCoin(string login, int coinId, string author) { string targetEmail = new UserServices().GetByLogin(login).Email; Coin coin = new CoinServices().GetById(coinId); MailAddress to = new MailAddress(targetEmail); MailAddress from = new MailAddress("*****@*****.**", "SiteWebCoin"); MailMessage message = new MailMessage(from, to); message.Subject = "J'ai cette pièce pour toi!"; message.Body = @"La pièce concernée est : " + coin.Country.Name + "/" + coin.Year + "/" + coin.Valeur + "/" + coin.Name + "\n\n " + author; SmtpClient client = new SmtpClient("email-smtp.eu-west-1.amazonaws.com"); client.UseDefaultCredentials = true; client.DeliveryMethod = SmtpDeliveryMethod.Network; client.Credentials = new System.Net.NetworkCredential("AKIAUX6VMGRQSNQVHWHR", "BGwON/Bkltv2GZNlMBk1l9cgt4dyMBK3/WjlYsMEiReI"); client.EnableSsl = true; client.Port = 587; try { client.Send(message); } catch (Exception ex) { Console.WriteLine("Exception caught in CreateTestMessage2(): {0}", ex.ToString()); } }
public IHttpActionResult Get(int id) { var coin = new CoinServices().GetById(id); if (coin == null) { return(NotFound()); } return(Ok(coin)); }
public IHttpActionResult Get([FromUri] FilterModel filter) { var coinsQuery = new CoinServices().GetAllRandomly(); if (filter.CountryId != null) { coinsQuery = coinsQuery.Where(m => m.CountryId == filter.CountryId); } return(Ok(coinsQuery.ToList())); }