public IHttpActionResult Update(NotificationTemplates item) { try { var identity = HttpContext.Current.User.Identity as ClaimsIdentity; AppUser = UserInfo.GetUser(identity); if (AppUser.IsAdmin) { return(Json(item.Save(), CamelCase)); } else { return(Unauthorized()); } } catch (Exception ex) { return(HandleException(ex)); } }
private static void GenerateEmailsFromTemplate(NotificationTemplates template) { var status = "Success"; try { // Based on List, generate emails, currently only OGEForm450 templates are available if (template.SharePointList == "OGEForm450") { GenerateEmailsForOGEForm450(template); } } catch (Exception ex) { status = "Error: " + ex.Message; } finally { // This may seem a little weird, why not just add frequency to DateTime.Now? // Well, eventually that would get skewed if this process takes any time to run. We want the time of day to be consistent. // So if Next Run Date is set to Midnight, it will always be at midnight. // The loop is basically just here in case it gets stuck or set back way in the past. // The loop ensures that the next run date that is set will be in the future. // Update Next Run Date while (template.NextRunDate < DateTime.UtcNow) { template.NextRunDate = GetNextRunDate((DateTime)template.NextRunDate, template.Frequency); } template.LastRunDate = DateTime.UtcNow; template.LastRunStatus = status; template.Save(); } }