protected override void PersistUpdatedItem(IUserGroup entity) { ((UserGroup)entity).UpdatingEntity(); var userGroupDto = UserGroupFactory.BuildDto(entity); Database.Update(userGroupDto); PersistAllowedSections(entity); }
protected override void PersistUpdatedItem(IUserGroup entity) { entity.UpdatingEntity(); var userGroupDto = UserGroupFactory.BuildDto(entity); Database.Update(userGroupDto); PersistAllowedSections(entity); entity.ResetDirtyProperties(); }
protected override void PersistNewItem(IUserGroup entity) { ((UserGroup)entity).AddingEntity(); var userGroupDto = UserGroupFactory.BuildDto(entity); var id = Convert.ToInt32(Database.Insert(userGroupDto)); entity.Id = id; PersistAllowedSections(entity); }
protected override IEnumerable <IUserGroup> PerformGetByQuery(IQuery <IUserGroup> query) { var sqlClause = GetBaseQuery(QueryType.Many); var translator = new SqlTranslator <IUserGroup>(sqlClause, query); var sql = translator.Translate(); AppendGroupBy(sql); sql.OrderBy <UserGroupDto>(x => x.Id); // required for references var dtos = Database.FetchOneToMany <UserGroupDto>(x => x.UserGroup2AppDtos, sql); return(dtos.Select(x => UserGroupFactory.BuildEntity(_shortStringHelper, x))); }
protected override IUserGroup PerformGet(int id) { var sql = GetBaseQuery(false); sql.Where(GetBaseWhereClause(), new { Id = id }); AppendGroupBy(sql); //must be included for relator to work sql.OrderBy <UserGroupDto>(x => x.Id, SqlSyntax); var dto = Database.Fetch <UserGroupDto, UserGroup2AppDto, UserGroupDto>(new UserGroupSectionRelator().Map, sql).FirstOrDefault(); if (dto == null) { return(null); } var userGroup = UserGroupFactory.BuildEntity(dto); return(userGroup); }
protected override IEnumerable <IUserGroup> PerformGetAll(params int[] ids) { var sql = GetBaseQuery(QueryType.Many); if (ids.Any()) { sql.WhereIn <UserGroupDto>(x => x.Id, ids); } else { sql.Where <UserGroupDto>(x => x.Id >= 0); } AppendGroupBy(sql); sql.OrderBy <UserGroupDto>(x => x.Id); // required for references var dtos = Database.FetchOneToMany <UserGroupDto>(x => x.UserGroup2AppDtos, sql); return(dtos.Select(x => UserGroupFactory.BuildEntity(_shortStringHelper, x))); }
protected override IUserGroup PerformGet(int id) { var sql = GetBaseQuery(QueryType.Single); sql.Where(GetBaseWhereClause(), new { id = id }); AppendGroupBy(sql); sql.OrderBy <UserGroupDto>(x => x.Id); // required for references var dto = Database.FetchOneToMany <UserGroupDto>(x => x.UserGroup2AppDtos, sql).FirstOrDefault(); if (dto == null) { return(null); } var userGroup = UserGroupFactory.BuildEntity(_shortStringHelper, dto); return(userGroup); }
public IEnumerable <IUserGroup> GetGroupsAssignedToSection(string sectionAlias) { // Here we're building up a query that looks like this, a sub query is required because the resulting structure // needs to still contain all of the section rows per user group. // SELECT * // FROM [umbracoUserGroup] // LEFT JOIN [umbracoUserGroup2App] // ON [umbracoUserGroup].[id] = [umbracoUserGroup2App].[user] // WHERE umbracoUserGroup.id IN (SELECT umbracoUserGroup.id // FROM [umbracoUserGroup] // LEFT JOIN [umbracoUserGroup2App] // ON [umbracoUserGroup].[id] = [umbracoUserGroup2App].[user] // WHERE umbracoUserGroup2App.app = 'content') Sql <ISqlContext> sql = GetBaseQuery(QueryType.Many); Sql <ISqlContext> innerSql = GetBaseQuery(QueryType.Ids); innerSql.Where("umbracoUserGroup2App.app = " + SqlSyntax.GetQuotedValue(sectionAlias)); sql.Where($"umbracoUserGroup.id IN ({innerSql.SQL})"); AppendGroupBy(sql); return(Database.Fetch <UserGroupDto>(sql).Select(x => UserGroupFactory.BuildEntity(_shortStringHelper, x))); }