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;
        }
Exemplo n.º 2
0
        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;
        }
Exemplo n.º 3
0
        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;
        }
Exemplo n.º 4
0
        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);
        }
Exemplo n.º 5
0
        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.
             */
        }
Exemplo n.º 6
0
 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;
 }
Exemplo n.º 7
0
        private void GetUserInfo()
        {
            Realms.Realm realm = Realms.Realm.GetInstance();
            CurrentUser = realm.All <User>().Last();

            UserEmail = CurrentUser.Email;
        }
Exemplo n.º 8
0
 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;
 }
Exemplo n.º 9
0
 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;
 }
Exemplo n.º 10
0
        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;
        }
Exemplo n.º 11
0
        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;
        }
Exemplo n.º 12
0
 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;
 }
Exemplo n.º 13
0
        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);
            }
        }
Exemplo n.º 14
0
 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;
 }
Exemplo n.º 15
0
        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;
        }
Exemplo n.º 16
0
        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;
        }
Exemplo n.º 17
0
        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;
        }
Exemplo n.º 18
0
        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;
        }
Exemplo n.º 19
0
 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());
 }
Exemplo n.º 20
0
        public async Task <IQueryable <T> > GetItemsAsync <T>() where T : RealmObject
        {
            Realms.Realm realm = await GetRealmAsync();

            return(realm.All <T>());
        }
Exemplo n.º 21
0
 /// <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));
 }
Exemplo n.º 23
0
 public List <TRealmObject> GetAll()
 {
     return(_currentRealm.All <TRealmObject>().ToList());
 }