public bool CanCreate(User user, Theme theme) { if (user == null) { return(false); } if (theme == null) { throw new ArgumentNullException("theme"); } if (theme.Open && ThemeRules.CanRead(user, theme)) { return(true); } else if (!theme.Open && SectionRules.CanEdit(user, theme.Section)) { return(true); } else { return(false); } }
private ThemeDTO CreateThemeDTO(Theme theme, User user, IEnumerable <Message> messages) { var mres = new List <MessageDTO>(); foreach (var message in messages) { mres.Add(GetDTO(message, user)); } return(new ThemeDTO { Name = theme.Name, Open = theme.Open, Messages = mres, Id = theme.Id, Route = GetRoute(theme), Access = new FullAccessDTO { CanCreateElements = MessageRules.CanCreate(user, theme), CanDelete = ThemeRules.CanDelete(user, theme), CanRead = ThemeRules.CanRead(user, theme), CanUpdate = ThemeRules.CanEdit(user, theme) } }); }