public void SetPropertiesFrom(IDatabaseTimeEntry entity, Realms.Realm realm) { IsDeleted = entity.IsDeleted; SyncStatus = entity.SyncStatus; LastSyncErrorMessage = entity.LastSyncErrorMessage; Id = entity.Id; var skipWorkspaceFetch = entity?.WorkspaceId == null || entity.WorkspaceId == 0; RealmWorkspace = skipWorkspaceFetch ? null : realm.All <RealmWorkspace>().Single(x => x.Id == entity.WorkspaceId); var skipProjectFetch = entity?.ProjectId == null || entity.ProjectId == 0; RealmProject = skipProjectFetch ? null : realm.All <RealmProject>().Single(x => x.Id == entity.ProjectId); var skipTaskFetch = entity?.TaskId == null || entity.TaskId == 0; RealmTask = skipTaskFetch ? null : realm.All <RealmTask>().Single(x => x.Id == entity.TaskId); Billable = entity.Billable; Start = entity.Start; Stop = entity.Stop; Description = entity.Description; RealmTags.Clear(); if (entity.TagIds != null) { var allRealmTags = entity.TagIds.Select(id => realm.All <RealmTag>().Single(x => x.Id == id)); foreach (var oneOfRealmTags in allRealmTags) { RealmTags.Add(oneOfRealmTags); } } At = entity.At; ServerDeletedAt = entity.ServerDeletedAt; var skipUserFetch = entity?.UserId == null || entity.UserId == 0; RealmUser = skipUserFetch ? null : realm.All <RealmUser>().Single(x => x.Id == entity.UserId); CreatedWith = entity.CreatedWith; }
public RealmTimeEntry(ITimeEntry entity, Realms.Realm realm) { Id = entity.Id; var skipWorkspaceFetch = entity?.WorkspaceId == null || entity.WorkspaceId == 0; RealmWorkspace = skipWorkspaceFetch ? null :realm.All <RealmWorkspace>().Single(x => x.Id == entity.WorkspaceId); var skipProjectFetch = entity?.ProjectId == null || entity.ProjectId == 0; RealmProject = skipProjectFetch ? null :realm.All <RealmProject>().Single(x => x.Id == entity.ProjectId); var skipTaskFetch = entity?.TaskId == null || entity.TaskId == 0; RealmTask = skipTaskFetch ? null :realm.All <RealmTask>().Single(x => x.Id == entity.TaskId); Billable = entity.Billable; Start = entity.Start; Stop = entity.Stop; Duration = entity.Duration; Description = entity.Description; Tags = entity.Tags; TagIds = entity.TagIds; At = entity.At; ServerDeletedAt = entity.ServerDeletedAt; var skipUserFetch = entity?.UserId == null || entity.UserId == 0; RealmUser = skipUserFetch ? null :realm.All <RealmUser>().Single(x => x.Id == entity.UserId); CreatedWith = entity.CreatedWith; IsDirty = true; }
public void SetPropertiesFrom(IDatabaseProject entity, Realms.Realm realm) { At = entity.At; ServerDeletedAt = entity.ServerDeletedAt; IsDeleted = entity.IsDeleted; SyncStatus = entity.SyncStatus; LastSyncErrorMessage = entity.LastSyncErrorMessage; var skipWorkspaceFetch = entity?.WorkspaceId == null || entity.WorkspaceId == 0; RealmWorkspace = skipWorkspaceFetch ? null : realm.All <RealmWorkspace>().Single(x => x.Id == entity.WorkspaceId || x.OriginalId == entity.WorkspaceId); var skipClientFetch = entity?.ClientId == null || entity.ClientId == 0; RealmClient = skipClientFetch ? null : realm.All <RealmClient>().Single(x => x.Id == entity.ClientId || x.OriginalId == entity.ClientId); Name = entity.Name; IsPrivate = entity.IsPrivate; Active = entity.Active; Color = entity.Color; Billable = entity.Billable; Template = entity.Template; AutoEstimates = entity.AutoEstimates; EstimatedHours = entity.EstimatedHours; Rate = entity.Rate; Currency = entity.Currency; ActualHours = entity.ActualHours; }
public void SetPropertiesFrom(IDatabaseTimeEntry entity, Realms.Realm realm) { At = entity.At; ServerDeletedAt = entity.ServerDeletedAt; IsDeleted = entity.IsDeleted; SyncStatus = entity.SyncStatus; LastSyncErrorMessage = entity.LastSyncErrorMessage; var skipWorkspaceFetch = entity?.WorkspaceId == null || entity.WorkspaceId == 0; RealmWorkspace = skipWorkspaceFetch ? null : realm.All <RealmWorkspace>().Single(x => x.Id == entity.WorkspaceId || x.OriginalId == entity.WorkspaceId); var skipProjectFetch = entity?.ProjectId == null || entity.ProjectId == 0; RealmProject = skipProjectFetch ? null : realm.All <RealmProject>().SingleOrDefault(x => x.Id == entity.ProjectId || x.OriginalId == entity.ProjectId); var skipTaskFetch = RealmProject == null || entity?.TaskId == null || entity.TaskId == 0; RealmTask = skipTaskFetch ? null : realm.All <RealmTask>().SingleOrDefault(x => x.Id == entity.TaskId || x.OriginalId == entity.TaskId); Billable = entity.Billable; Start = entity.Start; Duration = entity.Duration; Description = entity.Description; var tags = entity.TagIds?.Select(id => realm.All <RealmTag>().Single(x => x.Id == id || x.OriginalId == id)) ?? new RealmTag[0]; RealmTags.Clear(); tags.ForEach(RealmTags.Add); var skipUserFetch = entity?.UserId == null || entity.UserId == 0; RealmUser = skipUserFetch ? null : realm.All <RealmUser>().Single(x => x.Id == entity.UserId || x.OriginalId == entity.UserId); }
public void Insert(TRealmObject item) // 0 { var listaItem = _currentRealm.All <TRealmObject>().ToList(); // 1 var contadorId = 0; // 2 if (listaItem.Count != 0) // 3 { contadorId = listaItem.Max(r => r.ID); } item.ID = contadorId + 1; // 4 _currentRealm.Write(() => // 5 _currentRealm.Add(item)); /* * 0 - Objeto genérico que receberá o objeto do banco local. * 1 - Lista de itens armazenada no banco local. * 2 - Variável contador de IDs iniciada com zero. * 3 - Se lista de itens NÃO for zero, então retorna o maior * valor da lista da propriedade ID e salva na variável contador * 4 - ID recebe o valor do contado + 1. * 5 - O objeto é salvo no banco local. */ }
public RealmTask(ITask entity, Realms.Realm realm) { Id = entity.Id; Name = entity.Name; RealmProject = realm.All <RealmProject>().Single(x => x.Id == ProjectId); RealmWorkspace = realm.All <RealmWorkspace>().Single(x => x.Id == WorkspaceId); RealmUser = realm.All <RealmUser>().Single(x => x.Id == UserId); EstimatedSeconds = entity.EstimatedSeconds; Active = entity.Active; At = entity.At; TrackedSeconds = entity.TrackedSeconds; IsDirty = true; }
private void GetUserInfo() { Realms.Realm realm = Realms.Realm.GetInstance(); CurrentUser = realm.All <User>().Last(); UserEmail = CurrentUser.Email; }
public RealmTag(ITag entity, Realms.Realm realm) { Id = entity.Id; RealmWorkspace = realm.All <RealmWorkspace>().Single(x => x.Id == WorkspaceId); Name = entity.Name; At = entity.At; IsDirty = true; }
public RealmClient(IClient entity, Realms.Realm realm) { Id = entity.Id; RealmWorkspace = realm.All <RealmWorkspace>().Single(x => x.Id == WorkspaceId); Name = entity.Name; At = entity.At; ServerDeletedAt = entity.ServerDeletedAt; IsDirty = true; }
public RealmTask(ITask entity, Realms.Realm realm) { Id = entity.Id; Name = entity.Name; var skipProjectFetch = entity?.ProjectId == null || entity.ProjectId == 0; RealmProject = skipProjectFetch ? null :realm.All <RealmProject>().Single(x => x.Id == entity.ProjectId); var skipWorkspaceFetch = entity?.WorkspaceId == null || entity.WorkspaceId == 0; RealmWorkspace = skipWorkspaceFetch ? null :realm.All <RealmWorkspace>().Single(x => x.Id == entity.WorkspaceId); var skipUserFetch = entity?.UserId == null || entity.UserId == 0; RealmUser = skipUserFetch ? null :realm.All <RealmUser>().Single(x => x.Id == entity.UserId); EstimatedSeconds = entity.EstimatedSeconds; Active = entity.Active; At = entity.At; TrackedSeconds = entity.TrackedSeconds; IsDirty = true; }
public RealmTag(ITag entity, Realms.Realm realm) { Id = entity.Id; var skipWorkspaceFetch = entity?.WorkspaceId == null || entity.WorkspaceId == 0; RealmWorkspace = skipWorkspaceFetch ? null :realm.All <RealmWorkspace>().Single(x => x.Id == entity.WorkspaceId); Name = entity.Name; At = entity.At; IsDirty = true; }
public RealmTimeEntry(ITimeEntry entity, Realms.Realm realm) { Id = entity.Id; RealmWorkspace = realm.All <RealmWorkspace>().Single(x => x.Id == WorkspaceId); RealmProject = realm.All <RealmProject>().Single(x => x.Id == ProjectId); RealmTask = realm.All <RealmTask>().Single(x => x.Id == TaskId); Billable = entity.Billable; Start = entity.Start; Stop = entity.Stop; Duration = entity.Duration; Description = entity.Description; Tags = entity.Tags; TagIds = entity.TagIds; At = entity.At; ServerDeletedAt = entity.ServerDeletedAt; RealmUser = realm.All <RealmUser>().Single(x => x.Id == UserId); CreatedWith = entity.CreatedWith; IsDirty = true; }
public void SetPropertiesFrom(IDatabaseWorkspaceFeatureCollection entity, Realms.Realm realm) { var skipWorkspaceFetch = entity?.WorkspaceId == null || entity.WorkspaceId == 0; RealmWorkspace = skipWorkspaceFetch ? null : realm.All <RealmWorkspace>().Single(x => x.Id == entity.WorkspaceId || x.OriginalId == entity.WorkspaceId); foreach (var oneOfFeatures in entity.Features) { var oneOfRealmFeatures = RealmWorkspaceFeature.FindOrCreate(oneOfFeatures, realm); RealmWorkspaceFeatures.Add(oneOfRealmFeatures); } }
public RealmProject(IProject entity, Realms.Realm realm) { Id = entity.Id; RealmWorkspace = realm.All <RealmWorkspace>().Single(x => x.Id == WorkspaceId); RealmClient = realm.All <RealmClient>().Single(x => x.Id == ClientId); Name = entity.Name; IsPrivate = entity.IsPrivate; Active = entity.Active; At = entity.At; ServerDeletedAt = entity.ServerDeletedAt; Color = entity.Color; Billable = entity.Billable; Template = entity.Template; AutoEstimates = entity.AutoEstimates; EstimatedHours = entity.EstimatedHours; Rate = entity.Rate; Currency = entity.Currency; ActualHours = entity.ActualHours; IsDirty = true; }
public void SetPropertiesFrom(IDatabaseTask entity, Realms.Realm realm) { At = entity.At; IsDeleted = entity.IsDeleted; SyncStatus = entity.SyncStatus; LastSyncErrorMessage = entity.LastSyncErrorMessage; Name = entity.Name; var skipProjectFetch = entity?.ProjectId == null || entity.ProjectId == 0; RealmProject = skipProjectFetch ? null : realm.All <RealmProject>().Single(x => x.Id == entity.ProjectId || x.OriginalId == entity.ProjectId); var skipWorkspaceFetch = entity?.WorkspaceId == null || entity.WorkspaceId == 0; RealmWorkspace = skipWorkspaceFetch ? null : realm.All <RealmWorkspace>().Single(x => x.Id == entity.WorkspaceId || x.OriginalId == entity.WorkspaceId); var skipUserFetch = entity?.UserId == null || entity.UserId == 0; RealmUser = skipUserFetch ? null : realm.All <RealmUser>().Single(x => x.Id == entity.UserId || x.OriginalId == entity.UserId); EstimatedSeconds = entity.EstimatedSeconds; Active = entity.Active; TrackedSeconds = entity.TrackedSeconds; }
public RealmClient(IClient entity, Realms.Realm realm) { Id = entity.Id; var skipWorkspaceFetch = entity?.WorkspaceId == null || entity.WorkspaceId == 0; RealmWorkspace = skipWorkspaceFetch ? null :realm.All <RealmWorkspace>().Single(x => x.Id == entity.WorkspaceId); Name = entity.Name; At = entity.At; ServerDeletedAt = entity.ServerDeletedAt; IsDirty = true; }
public void SetPropertiesFrom(IDatabaseTag entity, Realms.Realm realm) { IsDeleted = entity.IsDeleted; SyncStatus = entity.SyncStatus; LastSyncErrorMessage = entity.LastSyncErrorMessage; Id = entity.Id; var skipWorkspaceFetch = entity?.WorkspaceId == null || entity.WorkspaceId == 0; RealmWorkspace = skipWorkspaceFetch ? null : realm.All <RealmWorkspace>().Single(x => x.Id == entity.WorkspaceId); Name = entity.Name; At = entity.At; }
public void SetPropertiesFrom(IDatabaseClient entity, Realms.Realm realm) { At = entity.At; ServerDeletedAt = entity.ServerDeletedAt; IsDeleted = entity.IsDeleted; SyncStatus = entity.SyncStatus; LastSyncErrorMessage = entity.LastSyncErrorMessage; var skipWorkspaceFetch = entity?.WorkspaceId == null || entity.WorkspaceId == 0; RealmWorkspace = skipWorkspaceFetch ? null : realm.All <RealmWorkspace>().Single(x => x.Id == entity.WorkspaceId || x.OriginalId == entity.WorkspaceId); Name = entity.Name; }
internal IEnumerable <BookInfo> GetBookInfo() { realm.Write(() => { for (int i = 0; i < BookNames.Count(); i++) { var book = new BookInfo() { BookName = BookNames[i], BookDescription = BookDescriptions[i], BookAuthor = BookAuthers[i], }; realm.Add(book); } }); return(realm.All <BookInfo>().AsRealmCollection()); }
public async Task <IQueryable <T> > GetItemsAsync <T>() where T : RealmObject { Realms.Realm realm = await GetRealmAsync(); return(realm.All <T>()); }
/// <summary> /// Gets all the realm objects. /// </summary> /// <returns></returns> public IQueryable <TRealmObject> GetAll() { return(_currentRealm.All <TRealmObject>()); }
public IQueryable <dynamic> QueryAll(string className) { ConfigureInstance(); return(_realm.All(className)); }
public List <TRealmObject> GetAll() { return(_currentRealm.All <TRealmObject>().ToList()); }