Exemplo n.º 1
0
 private field_value_versions MapFieldValueVersions(field_values fieldValue)
 {
     return(new field_value_versions
     {
         CreatedAt = fieldValue.CreatedAt,
         UpdatedAt = fieldValue.UpdatedAt,
         Value = fieldValue.Value,
         Latitude = fieldValue.Latitude,
         Longitude = fieldValue.Longitude,
         Altitude = fieldValue.Altitude,
         Heading = fieldValue.Heading,
         Date = fieldValue.Date,
         Accuracy = fieldValue.Accuracy,
         UploadedDataId = fieldValue.UploadedDataId,
         Version = fieldValue.Version,
         CaseId = fieldValue.CaseId,
         FieldId = fieldValue.FieldId,
         WorkerId = fieldValue.WorkerId,
         WorkflowState = fieldValue.WorkflowState,
         CheckListId = fieldValue.CheckListId,
         CheckListDuplicateId = fieldValue.CheckListDuplicateId,
         DoneAt = fieldValue.DoneAt,
         FieldValueId = fieldValue.Id
     });
 }
Exemplo n.º 2
0
        public async Task Update(MicrotingDbContext dbContext)
        {
            field_values fieldValues = await dbContext.field_values.FirstOrDefaultAsync(x => x.Id == Id);

            if (fieldValues == null)
            {
                throw new NullReferenceException($"Could not find Field Value with Id: {Id}");
            }

            fieldValues.DoneAt               = DoneAt;
            fieldValues.Date                 = Date;
            fieldValues.WorkerId             = WorkerId;
            fieldValues.CaseId               = CaseId;
            fieldValues.FieldId              = FieldId;
            fieldValues.CheckListId          = CheckListId;
            fieldValues.CheckListDuplicateId = CheckListDuplicateId;
            fieldValues.UploadedDataId       = UploadedDataId;
            fieldValues.Value                = Value;
            fieldValues.Latitude             = Latitude;
            fieldValues.Longitude            = Longitude;
            fieldValues.Altitude             = Altitude;
            fieldValues.Heading              = Heading;
            fieldValues.Accuracy             = Accuracy;

            if (dbContext.ChangeTracker.HasChanges())
            {
                fieldValues.UpdatedAt = DateTime.UtcNow;
                fieldValues.Version  += 1;

                dbContext.field_value_versions.Add(MapFieldValueVersions(fieldValues));
                await dbContext.SaveChangesAsync().ConfigureAwait(false);
            }
        }
Exemplo n.º 3
0
        public async Task Delete(MicrotingDbContext dbContext)
        {
            field_values fieldValues = await dbContext.field_values.FirstOrDefaultAsync(x => x.Id == Id);

            if (fieldValues == null)
            {
                throw new NullReferenceException($"Could not find Field Value with Id: {Id}");
            }

            fieldValues.WorkflowState = Constants.Constants.WorkflowStates.Removed;

            if (dbContext.ChangeTracker.HasChanges())
            {
                fieldValues.UpdatedAt = DateTime.UtcNow;
                fieldValues.Version  += 1;

                dbContext.field_value_versions.Add(MapFieldValueVersions(fieldValues));
                await dbContext.SaveChangesAsync().ConfigureAwait(false);
            }
        }