示例#1
0
 public static ReportTask ToReportTask(ReportTaskStored storedTask)
 {
     return(new ReportTask
     {
         Id = storedTask.Id,
         CurrentState = storedTask.CurrentState,
         IsPublic = storedTask.IsPublic,
         Problems = storedTask.Problems,
         Theme = storedTask.Theme,
         Url = storedTask.Url,
         DateItemIdentifier = new ReportDateItemIdentifier
         {
             TeamId = storedTask.TeamId,
             Date = storedTask.TaskDate,
             UserId = storedTask.UserId
         }
     });
 }
        public Task SaveAsync(ReportTask reportTask)
        {
            if (reportTask == null)
            {
                throw new ArgumentNullException(nameof(reportTask));
            }
            if (reportTask.DateItemIdentifier == null)
            {
                throw new ArgumentNullException(nameof(ReportTask.DateItemIdentifier));
            }

            return(queryExecuter.QueryAsync(async connection =>
            {
                var saveParameters = new ReportTaskStored
                {
                    Id = reportTask.Id,
                    UserId = reportTask.DateItemIdentifier.UserId,
                    TeamId = reportTask.DateItemIdentifier.TeamId,
                    TaskDate = reportTask.DateItemIdentifier.Date,
                    IsPublic = reportTask.IsPublic,
                    Url = reportTask.Url,
                    Theme = reportTask.Theme,
                    CurrentState = reportTask.CurrentState,
                    Problems = reportTask.Problems,
                };
                var saveResult = await connection.ExecuteAsync(SaveQuery, saveParameters).ConfigureAwait(false);
                Log.Information("ReportTask ({Id}, {UserId}, {TeamId}, {TaskDate}, {IsPublic}, {Url}, {Theme}, {CurrentState}, {Problems}) " +
                                "inserted with result {SaveResult}",
                                reportTask.Id,
                                reportTask.DateItemIdentifier.UserId,
                                reportTask.DateItemIdentifier.TeamId,
                                reportTask.DateItemIdentifier.Date,
                                reportTask.IsPublic,
                                reportTask.Url,
                                reportTask.Theme,
                                reportTask.CurrentState,
                                reportTask.Problems,
                                saveResult);
            }));
        }