public ProjectUserData Import (IDataStoreContext ctx, ProjectUserJson json, Guid? localIdHint = null, ProjectUserData mergeBase = null)
        {
            var data = GetByRemoteId<ProjectUserData> (ctx, json.Id.Value, localIdHint);

            var merger = mergeBase != null ? new ProjectUserMerger (mergeBase) : null;
            if (merger != null && data != null)
                merger.Add (new ProjectUserData (data));

            if (json.DeletedAt.HasValue) {
                if (data != null) {
                    ctx.Delete (data);
                    data = null;
                }
            } else if (merger != null || ShouldOverwrite (data, json)) {
                data = data ?? new ProjectUserData ();
                ImportJson (ctx, data, json);

                if (merger != null) {
                    merger.Add (data);
                    data = merger.Result;
                }

                data = ctx.Put (data);
            }

            return data;
        }
예제 #2
0
 public ProjectUserData (ProjectUserData other) : base (other)
 {
     IsManager = other.IsManager;
     HourlyRate = other.HourlyRate;
     ProjectId = other.ProjectId;
     UserId = other.UserId;
 }
예제 #3
0
 public ProjectUserData(ProjectUserData other) : base(other)
 {
     IsManager  = other.IsManager;
     HourlyRate = other.HourlyRate;
     ProjectId  = other.ProjectId;
     UserId     = other.UserId;
 }
        private static void ImportJson (IDataStoreContext ctx, ProjectUserData data, ProjectUserJson json)
        {
            var projectId = GetLocalId<ProjectData> (ctx, json.ProjectId);
            var userId = GetLocalId<UserData> (ctx, json.UserId);

            data.HourlyRate = json.HourlyRate;
            data.IsManager = json.IsManager;
            data.ProjectId = projectId;
            data.UserId = userId;

            ImportCommonJson (data, json);
        }
        public ProjectUserJson Export (IDataStoreContext ctx, ProjectUserData data)
        {
            var projectId = GetRemoteId<ProjectData> (ctx, data.ProjectId);
            var userId = GetRemoteId<UserData> (ctx, data.UserId);

            return new ProjectUserJson () {
                Id = data.RemoteId,
                ModifiedAt = data.ModifiedAt.ToUtc (),
                HourlyRate = data.HourlyRate,
                IsManager = data.IsManager,
                ProjectId = projectId,
                UserId = userId,
            };
        }
        public ProjectUserData Import (IDataStoreContext ctx, ProjectUserJson json, Guid? localIdHint = null, ProjectUserData mergeBase = null)
        {
            var log = ServiceContainer.Resolve<ILogger> ();

            var data = GetByRemoteId<ProjectUserData> (ctx, json.Id.Value, localIdHint);

            var merger = mergeBase != null ? new ProjectUserMerger (mergeBase) : null;
            if (merger != null && data != null) {
                merger.Add (new ProjectUserData (data));
            }

            if (json.DeletedAt.HasValue) {
                if (data != null) {
                    log.Info (Tag, "Deleting local data for {0}.", data.ToIdString ());
                    ctx.Delete (data);
                    data = null;
                }
            } else if (merger != null || ShouldOverwrite (data, json)) {
                data = data ?? new ProjectUserData ();
                ImportJson (ctx, data, json);

                if (merger != null) {
                    merger.Add (data);
                    data = merger.Result;
                }

                if (merger != null) {
                    log.Info (Tag, "Importing {0}, merging with local data.", data.ToIdString ());
                } else {
                    log.Info (Tag, "Importing {0}, replacing local data.", data.ToIdString ());
                }

                data = ctx.Put (data);
            } else {
                log.Info (Tag, "Skipping import of {0}.", json.ToIdString ());
            }

            return data;
        }
예제 #7
0
 public static ProjectUserData Import (this ProjectUserJson json, IDataStoreContext ctx,
                                       Guid? localIdHint = null, ProjectUserData mergeBase = null)
 {
     var converter = ServiceContainer.Resolve<ProjectUserJsonConverter> ();
     return converter.Import (ctx, json, localIdHint, mergeBase);
 }