Ejemplo n.º 1
0
 private unit_versions MapVersions(units unit)
 {
     return(new unit_versions
     {
         WorkflowState = unit.WorkflowState,
         Version = unit.Version,
         CreatedAt = unit.CreatedAt,
         UpdatedAt = unit.UpdatedAt,
         MicrotingUid = unit.MicrotingUid,
         SiteId = unit.SiteId,
         CustomerNo = unit.CustomerNo,
         OtpCode = unit.OtpCode,
         UnitId = unit.Id,
         Manufacturer = unit.Manufacturer,
         Model = unit.Model,
         Os = unit.Os,
         OsVersion = unit.OsVersion,
         eFormVersion = unit.eFormVersion,
         InSightVersion = unit.InSightVersion,
         Note = unit.Note,
         SerialNumber = unit.SerialNumber,
         LastIp = unit.LastIp,
         SeparateFetchSend = unit.SeparateFetchSend,
         LeftMenuEnabled = unit.LeftMenuEnabled,
         SyncDialog = unit.SyncDialog,
         PushEnabled = unit.PushEnabled,
         SyncDelayEnabled = unit.SyncDelayEnabled,
         SyncDefaultDelay = unit.SyncDefaultDelay,
         SyncDelayPrCheckList = unit.SyncDelayPrCheckList
     });
 }
Ejemplo n.º 2
0
        public async Task Delete(MicrotingDbContext dbContext)
        {
            units unit = await dbContext.units.FirstOrDefaultAsync(x => x.Id == Id);

            if (unit == null)
            {
                throw new NullReferenceException($"Could not find Unit with Id: {Id}");
            }

            unit.WorkflowState = Constants.Constants.WorkflowStates.Removed;

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

                dbContext.unit_versions.Add(MapVersions(unit));
                await dbContext.SaveChangesAsync().ConfigureAwait(false);
            }
        }
Ejemplo n.º 3
0
        public async Task Update(MicrotingDbContext dbContext)
        {
            units unit = await dbContext.units.FirstOrDefaultAsync(x => x.Id == Id);

            if (unit == null)
            {
                throw new NullReferenceException($"Could not find Unit with Id: {Id}");
            }

            unit.SiteId               = SiteId;
            unit.MicrotingUid         = MicrotingUid;
            unit.OtpCode              = OtpCode;
            unit.Model                = Model;
            unit.Manufacturer         = Manufacturer;
            unit.eFormVersion         = eFormVersion;
            unit.InSightVersion       = InSightVersion;
            unit.Os                   = Os;
            unit.OsVersion            = OsVersion;
            unit.Note                 = Note;
            unit.CustomerNo           = CustomerNo;
            unit.SerialNumber         = SerialNumber;
            unit.LastIp               = LastIp;
            unit.SeparateFetchSend    = SeparateFetchSend;
            unit.LeftMenuEnabled      = LeftMenuEnabled;
            unit.SyncDialog           = SyncDialog;
            unit.PushEnabled          = PushEnabled;
            unit.SyncDelayEnabled     = SyncDelayEnabled;
            unit.SyncDefaultDelay     = SyncDefaultDelay;
            unit.SyncDelayPrCheckList = SyncDelayPrCheckList;

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

                dbContext.unit_versions.Add(MapVersions(unit));
                await dbContext.SaveChangesAsync().ConfigureAwait(false);
            }
        }