public List <string> getUpFiveStocks() { var AllUsers = _registration.ReturnAll(); List <string> StocksToCheckAgainstUpFive = new List <string> { }; foreach (var user in AllUsers) { if (user.UpFive) { if (user.Stocks == null) { continue; } foreach (var stock in user.Stocks) { StocksToCheckAgainstUpFive.Add(stock.stock); } } } return(StocksToCheckAgainstUpFive); }
public List <RegisteredUser> DeleteUser([FromBody] int id) { _registration.Delete(id); _registration.Commit(); return(_registration.ReturnAll()); }
public async Task <string> Send(Email currentEmail, string ticker) { var AllUsers = _registration.ReturnAll(); var client = new SendGridClient("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"); var from = new EmailAddress(currentEmail.From); var subject = currentEmail.Subject; var plainTextContent = currentEmail.Content; var htmlContent = "<p>" + currentEmail.Content + "</p>"; if (currentEmail.Admin) { foreach (var recipiant in AllUsers) { if (recipiant.Admin) { var to = new EmailAddress(recipiant.Email); var msg = MailHelper.CreateSingleEmail(from, to, subject, plainTextContent, htmlContent); var response = await client.SendEmailAsync(msg); } } return("sent"); } else if (currentEmail.UpFive) { foreach (var recipiant in AllUsers) { if (recipiant.UpFive) { foreach (var Ticker in recipiant.Stocks) { if (Ticker.stock == ticker) { var to = new EmailAddress(recipiant.Email); var msg = MailHelper.CreateSingleEmail(from, to, subject, plainTextContent, htmlContent); var response = await client.SendEmailAsync(msg); } } } } return("sent"); } else if (currentEmail.DownFive) { foreach (var recipiant in AllUsers) { if (recipiant.DownFive) { foreach (var Ticker in recipiant.Stocks) { if (Ticker.stock == ticker) { var to = new EmailAddress(recipiant.Email); var msg = MailHelper.CreateSingleEmail(from, to, subject, plainTextContent, htmlContent); var response = await client.SendEmailAsync(msg); } } } } return("sent"); } else if (currentEmail.MovingAvg) { foreach (var recipiant in AllUsers) { if (recipiant.MovingAvg) { foreach (var Ticker in recipiant.Stocks) { if (Ticker.stock == ticker) { var to = new EmailAddress(recipiant.Email); var msg = MailHelper.CreateSingleEmail(from, to, subject, plainTextContent, htmlContent); var response = await client.SendEmailAsync(msg); } } } } return("sent"); } else { return("error"); } }