} // ReadAll public async Task <ApplicationUser> CreateAsync(ApplicationUser applicationUser) { _db.Users.Add(applicationUser); await _db.SaveChangesAsync(); if (Config.AuditingOn) { var auditChange = new AuditChange(); auditChange.CreateAuditTrail(AuditActionType.CREATE, applicationUser.Id, new ApplicationUser(), applicationUser); await _auditRepo.CreateAsync(auditChange); } return(applicationUser); } // CreateAsync
} // ReadAll public async Task <Developer> CreateAsync(Developer developer) { _db.Developers.Add(developer); await _db.SaveChangesAsync(); if (Config.AuditingOn) { var auditChange = new AuditChange(); auditChange.CreateAuditTrail(AuditActionType.CREATE, developer.Id, new Doctor(), developer); await _auditRepo.CreateAsync(auditChange); } // if return(developer); } // CreateAsync
} // ReadAll public async Task<GlucoseEntry> CreateAsync( GlucoseEntry glucoseEntry ) { _db.GlucoseEntries.Add( glucoseEntry ); await _db.SaveChangesAsync(); if( Config.AuditingOn ) { var auditChange = new AuditChange(); auditChange.CreateAuditTrail( AuditActionType.CREATE, glucoseEntry.Id.ToString(), new GlucoseEntry(), glucoseEntry ); await _auditRepo.CreateAsync( auditChange ); } // if return glucoseEntry; } // Create
} // ReadAll public async Task<ExerciseEntry> CreateAsync( ExerciseEntry exerciseentry ) { _db.ExerciseEntries.Add( exerciseentry ); await _db.SaveChangesAsync(); if( Config.AuditingOn ) { var auditChange = new AuditChange(); auditChange.CreateAuditTrail( AuditActionType.CREATE, exerciseentry.Id.ToString(), new ExerciseEntry(), exerciseentry ); await _auditRepo.CreateAsync( auditChange ); } // if return exerciseentry; } // Create
} // ReadAll public async Task<MealEntry> CreateAsync( MealEntry mealentry ) { _db.MealEntries.Add( mealentry ); await _db.SaveChangesAsync(); if( Config.AuditingOn ) { var auditChange = new AuditChange(); auditChange.CreateAuditTrail( AuditActionType.CREATE, mealentry.Id.ToString(), new MealEntry(), mealentry ); await _auditRepo.CreateAsync( auditChange ); } // if return mealentry; } // Create
} // ReadAll public async Task<Patient> CreateAsync( Patient patient ) { _db.Patients.Add( patient ); _db.Entry( patient.PatientSignedHIPAANotice ).State = EntityState.Unchanged; await _db.SaveChangesAsync(); if( Config.AuditingOn ) { var auditChange = new AuditChange(); auditChange.CreateAuditTrail( AuditActionType.CREATE, patient.Id, new Patient(), patient ); await _auditRepo.CreateAsync( auditChange ); } // if return patient; } // Create
} // ReadAll public async Task <HIPAAPrivacyNotice> CreateAsync(HIPAAPrivacyNotice privacyNotice) { privacyNotice.CreatedAt = DateTime.Now; privacyNotice.UpdatedAt = DateTime.Now; await _db.HIPAAPrivacyNotices.AddAsync(privacyNotice); await _db.SaveChangesAsync(); if (Config.AuditingOn) { var auditChange = new AuditChange(); auditChange.CreateAuditTrail(AuditActionType.CREATE, privacyNotice.Id.ToString(), new HIPAAPrivacyNotice(), privacyNotice); await _auditRepo.CreateAsync(auditChange); } // if return(privacyNotice); } // CreateAsync
} // ReadAsync public async Task<Doctor> CreateAsync( Doctor doctor ) { doctor.SecurityStamp = Guid.NewGuid().ToString(); _db.Doctors.Add( doctor ); await _db.SaveChangesAsync(); if( Config.AuditingOn ) { var auditChange = new AuditChange(); auditChange.CreateAuditTrail( AuditActionType.CREATE, doctor.Id, new Doctor(), doctor ); await _auditRepo.CreateAsync( auditChange ); } // if return doctor; } // Create
} // ReadAll public async Task<MealItem> CreateAsync( Guid mealEntryId, MealItem mealItem ) { var mealEntry = await _db.MealEntries .Include( o => o.MealItems ) .SingleOrDefaultAsync( o => o.Id == mealEntryId ); if ( mealEntry != null ) { mealEntry.MealItems.Add( mealItem ); // Associate item with the entry mealItem.Meal = mealEntry; // Associate the entry with the item await _db.SaveChangesAsync(); }// End if mealEntry not null statement. if( Config.AuditingOn ) { var auditChange = new AuditChange(); auditChange.CreateAuditTrail( AuditActionType.CREATE, mealItem.Id.ToString(), new MealItem(), mealItem ); await _auditRepo.CreateAsync( auditChange ); } // if return mealItem; } // CreateAsync
public async Task <IActionResult> Run([HttpTrigger(AuthorizationLevel.Function, "post", Route = "facilities/{facilityId}/audits")] HttpRequest req, ILogger log, string facilityId) { try { var facility = _facilityRepository.FindById(facilityId); if (facility == null) { return(new NotFoundResult()); } var claims = req.GetClaimsPrincipal(); var requestBody = await new StreamReader(req.Body).ReadToEndAsync(); var audit = JsonConvert.DeserializeObject <AuditDto>(requestBody); await ProcessPhotosAsync(audit.Groups); var groups = audit.Groups.Select(x => x.CreateEntity()).ToList(); var entity = new Entities.Audit { PartitionKey = $"{DateTime.Now.Year}{DateTime.Now.Month}", RowKey = Guid.NewGuid().ToString(), Timestamp = _dateTimeService.TableEntityTimeStamp, FacilityId = facilityId, StartTimeUtc = audit.StartTimeUtc, FinishTimeUtc = audit.FinishTimeUtc, GroupsJson = JsonConvert.SerializeObject(groups), CreatedBy = claims.ClientId(), CreatedAt = _dateTimeService.CurrentUtcDateTime }; var result = await _auditRepository.CreateAsync(entity); return(new OkObjectResult(result)); } catch (Exception e) { return(new ExceptionResult(e, true)); } }