Esempio n. 1
0
        public async Task <IEnumerable <AuditLogDto> > FetchAuditLogsAsync()
        {
            this.AuditLogCollection.Clear();

            var Count = await JSRuntime.InvokeAsync <string>("FetchLogCount");

            LogCount = int.Parse(Count);

            for (int i = 0; i < LogCount; i++)
            {
                var log = await JSRuntime.InvokeAsync <object>("FetchLogs", i.ToString());

                var auditlog = JsonSerializer.Deserialize <Dictionary <string, object> >(log.ToString());

                var datetimestamp = auditlog["datetimestamp"];
                var user          = auditlog["user"];
                var change        = auditlog["change"];
                var oldvalue      = auditlog["oldvalue"];
                var newvalue      = auditlog["newvalue"];

                var auditLogDto = new AuditLogDto()
                {
                    DateTimeStamp = datetimestamp.ToString(),
                    User          = user.ToString(),
                    Change        = change.ToString(),
                    OldValue      = oldvalue.ToString(),
                    NewValue      = newvalue.ToString()
                };

                AuditLogCollection.Add(auditLogDto);
            }

            return(AuditLogCollection);
        }
Esempio n. 2
0
        public async Task DeletePippetteAsync(Guid pippetteId)
        {
            if (pippetteId == null)
            {
                throw new ArgumentNullException("pippetteId");
            }

            var pippette = await DBContext.Pippettes
                           .Include(p => p.Manufacture)
                           .Include(p => p.Location)
                           .Include(p => p.PippetteUser)
                           .Where(p => p.Pippette_Id == pippetteId).FirstOrDefaultAsync();

            var oldValue = pippette.ToString();

            DBContext.Pippettes.Remove(pippette);
            await DBContext.SaveChangesAsync();

            var auditLogDto = new AuditLogDto()
            {
                DateTimeStamp = DateTime.UtcNow.Date.ToString("ddMMyyyyhhmmss"),
                User          = "",
                Change        = "Deleted a pippette",
                OldValue      = oldValue,
                NewValue      = string.Empty
            };

            await AuditDataService.AddLog(auditLogDto);
        }
Esempio n. 3
0
        public async Task UpdatePippetteAsync(Guid pippetteId, PippetteDataDto pippetteDataDto)
        {
            if (pippetteId == null)
            {
                throw new ArgumentNullException("pippetteId");
            }
            if (pippetteDataDto == null)
            {
                throw new ArgumentNullException("pippetteDataDto");
            }

            var manufacture = await DBContext.Manufactures.Where(m => m.Manufacture_Name == pippetteDataDto.Manufacture_Name).FirstOrDefaultAsync();

            var location = await DBContext.Locations.Where(l => l.Location_Name == pippetteDataDto.Location_Name).FirstOrDefaultAsync();

            var user = await DBContext.PippetteUsers.Where(u => u.Pippette_User_Name == pippetteDataDto.Pippette_User_Name).FirstOrDefaultAsync();

            var pippette = await DBContext.Pippettes
                           .Include(p => p.Manufacture)
                           .Include(p => p.Location)
                           .Include(p => p.PippetteUser)
                           .Where(p => p.Pippette_Id == pippetteId).FirstOrDefaultAsync();

            var oldValue = pippette.ToString();

            pippette.Manufacture_Id   = manufacture.Manufacture_Id;
            pippette.Location_Id      = location.Location_Id;
            pippette.Pippette_User_Id = user.Pippette_User_Id;
            pippette.ModelName        = pippetteDataDto.ModelName;
            pippette.SerialNumber     = pippetteDataDto.SerialNumber;
            pippette.UsageFrequency   = pippetteDataDto.UsageFrequency;

            DBContext.Pippettes.Attach(pippette);
            await DBContext.SaveChangesAsync();

            var auditLogDto = new AuditLogDto()
            {
                DateTimeStamp = DateTime.UtcNow.Date.ToString("ddMMyyyyhhmmss"),
                User          = pippetteDataDto.Pippette_User_Name,
                Change        = "Updated a pippette",
                OldValue      = oldValue,
                NewValue      = pippetteDataDto.ToString()
            };

            await AuditDataService.AddLog(auditLogDto);
        }
Esempio n. 4
0
        public async Task AddPippetteAsync(PippetteDataDto pippetteDataDto)
        {
            if (pippetteDataDto == null)
            {
                throw new ArgumentNullException("pippetteDataDto");
            }

            var manufacture = await DBContext.Manufactures.Where(m => m.Manufacture_Name == pippetteDataDto.Manufacture_Name).FirstOrDefaultAsync();

            var location = await DBContext.Locations.Where(l => l.Location_Name == pippetteDataDto.Location_Name).FirstOrDefaultAsync();

            var user = await DBContext.PippetteUsers.Where(u => u.Pippette_User_Name == pippetteDataDto.Pippette_User_Name).FirstOrDefaultAsync();

            var pippette = new Pippette()
            {
                Pippette_Id      = Guid.NewGuid(),
                Manufacture_Id   = manufacture.Manufacture_Id,
                Location_Id      = location.Location_Id,
                Pippette_User_Id = user.Pippette_User_Id,
                ModelName        = pippetteDataDto.ModelName,
                SerialNumber     = pippetteDataDto.SerialNumber,
                UsageFrequency   = pippetteDataDto.UsageFrequency
            };

            await DBContext.Pippettes.AddAsync(pippette);

            await DBContext.SaveChangesAsync();

            var auditLogDto = new AuditLogDto()
            {
                DateTimeStamp = DateTime.UtcNow.Date.ToString("ddMMyyyyhhmmss"),
                User          = pippetteDataDto.Pippette_User_Name,
                Change        = "Inserted a pippette",
                OldValue      = string.Empty,
                NewValue      = pippetteDataDto.ToString()
            };

            await AuditDataService.AddLog(auditLogDto);
        }
Esempio n. 5
0
 public async Task AddLog(AuditLogDto auditLogDto)
 {
     await JSRuntime.InvokeVoidAsync("AddLog", auditLogDto.DateTimeStamp, auditLogDto.User, auditLogDto.Change, auditLogDto.OldValue, auditLogDto.NewValue);
 }