public async Task <List <PuckUser> > UsersToNotify(string path, NotifyActions action) { //var user = HttpContext.Current.User.Identity.Name; var strAction = action.ToString(); var metas = repo.GetPuckMeta() .Where(x => x.Name.Contains(":" + strAction /*+ ":"*/)) .Where( x => x.Key.Equals(path) && x.Name.Contains(":.:") || x.Key.StartsWith(path) && x.Name.Contains(":*:") ) .ToList(); var usernames = metas.Select(x => x.Value).ToList(); var users = new List <PuckUser>(); foreach (var username in usernames) { var user = await userManager.FindByNameAsync(username); if (user != null) { users.Add(user); } } return(users); }
public static string EmailTransform(string template, BaseModel model, NotifyActions action) { string date = DateTime.Now.ToShortDateString(); string time = DateTime.Now.ToShortTimeString(); string user = ""; string editUrl = ""; try { var hcontext = HttpContext.Current; user = hcontext?.User?.Identity?.Name ?? ""; var uri = hcontext?.Request?.GetUri() ?? PuckCache.FirstRequestUrl; editUrl = uri.Scheme + "://" + uri.Host + (uri.Port != 80 ?(":" + uri.Port):"") + "/puck?hash=" + HttpUtility.UrlEncode("content?id=" + model.Id.ToString() + "&variant=" + model.Variant); } catch (Exception ex) { PuckCache.PuckLog.Log(ex); } template = template .Replace("<!--Id-->", model.Id.ToString()) .Replace("<!--NodeName-->", model.NodeName) .Replace("<!--LastEditedBy-->", model.LastEditedBy) .Replace("<!--CreatedBy-->", model.CreatedBy) .Replace("<!--Path-->", model.Path) .Replace("<!--Created-->", model.Created.ToString("dd/MM/yyyy hh:mm:ss")) .Replace("<!--Updated-->", model.Updated.ToString("dd/MM/yyyy hh:mm:ss")) .Replace("<!--Revision-->", model.Revision.ToString()) .Replace("<!--Variant-->", model.Variant) .Replace("<!--Published-->", model.Published.ToString()) .Replace("<!--SortOrder-->", model.SortOrder.ToString()) .Replace("<!--TemplatePath-->", model.TemplatePath) .Replace("<!--TypeChain-->", model.TypeChain) .Replace("<!--Type-->", model.Type) .Replace("<!--__Verb__", action.ToString()) .Replace("<!--EditUrl-->", editUrl) .Replace("<!--Date-->", date) .Replace("<!--Time-->", time) .Replace("<!--User-->", user) ; return(template); }