/// <summary> /// Selects all data. /// </summary> /// <returns></returns> public override async Task <IEnumerable <IUser> > FindAllAsync() { using (CellentContext context = new CellentContext()) { return(Mapper.Convert(await context.Users.Include(d => d.Role.Rights).ToListAsync())); } }
/// <summary> /// Finds all with children asynchronous. /// </summary> /// <returns></returns> /// <exception cref="System.NotImplementedException"></exception> public virtual async Task <IEnumerable <IRole> > FindAllWithChildrenAsync() { using (CellentContext context = new CellentContext()) { return(Mapper.Convert(await context.Roles.ToListAsync()).ToList()); } }
public virtual IEnumerable <IResource> FindForCultureInfo(CultureInfo cultureInfo) { using (CellentContext context = new CellentContext()) { return(Mapper.Convert(context.Resources.Where(d => d.Language == cultureInfo.Name).ToList())); } }
public virtual Guid FindIdByDomainTypeName(string typeName) { using (CellentContext context = new CellentContext()) { return(context.DomainObjects.First(d => d.Type == typeName).Id); } }
public virtual IDomainObject FindByDomainTypeName(string typeName) { using (CellentContext context = new CellentContext()) { return(Mapper.Convert(context.DomainObjects.First(d => d.Type == typeName))); } }
public virtual IUser FindByName(string name) { using (CellentContext context = new CellentContext()) { return(Mapper.Convert(context.Users .Include(d => d.Role.Rights) .FirstOrDefault(d => d.Name.ToLower() == name.ToLower()))); } }
public virtual IUser FindById(Guid id) { using (CellentContext context = new CellentContext()) { return (Mapper.Convert(context.Users.Include(d => d.Role.Rights) .FirstOrDefault(d => d.Id == id))); } }
/// <summary> /// Finds all entries paged for culture information. /// </summary> /// <param name="page">The page.</param> /// <param name="pageSize">Size of the page.</param> /// <returns></returns> public virtual async Task <IEnumerable <IResource> > FindAllPagedAsync(int page, int pageSize) { using (CellentContext context = new CellentContext()) { return(Mapper.Convert(await context.Resources .OrderBy(d => d.Key) .Skip(page * pageSize) .Take(pageSize) .ToListAsync())); } }
/// <summary> /// Saves the or update. /// </summary> /// <param name="entity">The entity.</param> /// <returns></returns> public override async Task <IRole> SaveOrUpdateAsync(IRole entity) { IRole role = await base.SaveOrUpdateAsync(entity); using (CellentContext context = new CellentContext()) { RoleDao roleDao = await context.Roles.FirstOrDefaultAsync(d => d.Id == role.Id); await context.SaveChangesAsync(); role = Mapper.Convert(roleDao); return(role); } }
/// <summary> /// Saves the or update asynchronous. /// </summary> /// <param name="entity">The entity.</param> /// <returns></returns> public override async Task <IChangeLog> SaveOrUpdateAsync(IChangeLog entity) { ChangeLogDao dao = Mapper.Convert(entity); dao.ChangedAt = DateTime.Now; if (dao.ChangedBy == Guid.Empty) { dao.ChangedBy = CurrentUserId; } using (CellentContext context = new CellentContext()) { switch (dao.State) { case Constants.EntityState.Created: dao.CreatedAt = DateTime.Now; if (dao.CreatedBy == Guid.Empty) { dao.CreatedBy = CurrentUserId; } context.Set(dao.GetType()).Add(dao); break; case Constants.EntityState.Modified: context.Set(dao.GetType()).Attach(dao); context.Entry(dao).State = EntityState.Modified; break; } context.Entry(dao.DomainObject).State = EntityState.Unchanged; await context.SaveChangesAsync(); entity = Mapper.Convert(dao); EventAggregator.GetEvent <EntityUpdated>().Publish(entity); return(entity); } }