Beispiel #1
0
        public static HistoricalCaseNote AddCaseNoteForASpecificPersonToDb(HistoricalDataContext context, long personId, bool includeNoteContent = true)
        {
            var faker = new Faker();

            var noteTypeCode        = faker.Random.String2(5);
            var noteTypeDescription = faker.Random.String2(15);
            var noteType            = HistoricalTestHelper.CreateDatabaseNoteType(noteTypeCode, noteTypeDescription);

            context.HistoricalNoteTypes.Add(noteType);
            var savedWorker = HistoricalTestHelper.CreateDatabaseWorker();

            context.HistoricalWorkers.Add(savedWorker);

            var caseNoteId    = faker.Random.Long(min: 1);
            var savedCaseNote = HistoricalTestHelper.CreateDatabaseCaseNote(caseNoteId, personId, savedWorker, noteType);

            context.HistoricalCaseNotes.Add(savedCaseNote);
            context.SaveChanges();

            return(new HistoricalCaseNote
            {
                CreatedBy = $"{savedWorker.FirstNames} {savedWorker.LastNames}",
                CreatedByWorker = savedCaseNote.CreatedByWorker,
                Id = savedCaseNote.Id,
                LastUpdatedBy = savedCaseNote.LastUpdatedBy,
                Note = includeNoteContent == true ? savedCaseNote.Note : null,
                PersonId = savedCaseNote.PersonId,
                Title = savedCaseNote.Title,
                CreatedOn = savedCaseNote.CreatedOn,
                NoteType = noteType.Description,
                HistoricalNoteType = noteType
            });
        }
        public void WhenNoteTypeCannotBeFoundReturnsNullForNoteType()
        {
            var nonexistentNoteType = HistoricalTestHelper.CreateDatabaseNoteType("NONEXISTENT", "Non existent Case Note Type");
            var worker   = HistoricalTestHelper.CreateDatabaseWorker();
            var caseNote = HistoricalTestHelper.CreateDatabaseCaseNote(includeNoteType: false);

            HistoricalSocialCareContext.HistoricalNoteTypes.Add(nonexistentNoteType);
            HistoricalSocialCareContext.HistoricalWorkers.Add(worker);
            HistoricalSocialCareContext.HistoricalCaseNotes.Add(caseNote);
            HistoricalSocialCareContext.SaveChanges();

            var response = _historicalDataGateway.GetCaseNoteById(caseNote.Id);

            response?.NoteType.Should().BeNull();
        }
        private HistoricalCaseNote AddCaseNoteWithNoteTypeAndWorkerToDatabase(string workerFirstName         = null, string workerLastName = null,
                                                                              string workerEmailAddress      = null, long id               = 123, long personId = 123, string caseNoteType = "CASSUMASC",
                                                                              string caseNoteTypeDescription = "Case Summary (ASC)")
        {
            var noteType = HistoricalTestHelper.CreateDatabaseNoteType(caseNoteType, caseNoteTypeDescription);
            var worker   = HistoricalTestHelper.CreateDatabaseWorker(workerFirstName, workerLastName, workerEmailAddress);
            var caseNote = HistoricalTestHelper.CreateDatabaseCaseNote(id, personId, worker, noteType);

            HistoricalSocialCareContext.HistoricalNoteTypes.Add(noteType);
            HistoricalSocialCareContext.HistoricalWorkers.Add(worker);
            HistoricalSocialCareContext.HistoricalCaseNotes.Add(caseNote);
            HistoricalSocialCareContext.SaveChanges();

            return(caseNote);
        }
Beispiel #4
0
        private (HistoricalCaseNote, HistoricalNoteType, HistoricalWorker) AddCaseNoteWithNoteTypeAndWorkerToDatabase(long personId, long caseNoteId = 123)
        {
            var caseNoteType            = _faker.Random.String2(5);
            var caseNoteTypeDescription = _faker.Random.String2(15);

            var noteType = HistoricalTestHelper.CreateDatabaseNoteType(caseNoteType, caseNoteTypeDescription);

            HistoricalSocialCareContext.HistoricalNoteTypes.Add(noteType);

            var worker = HistoricalTestHelper.CreateDatabaseWorker();

            HistoricalSocialCareContext.HistoricalWorkers.Add(worker);

            var caseNote = HistoricalTestHelper.CreateDatabaseCaseNote(caseNoteId, personId, worker, noteType);

            HistoricalSocialCareContext.HistoricalCaseNotes.Add(caseNote);

            HistoricalSocialCareContext.SaveChanges();

            return(caseNote, noteType, worker);
        }
Beispiel #5
0
        public static HistoricalCaseNote AddCaseNoteWithNoteTypeAndWorkerToDatabase(HistoricalDataContext socialCareContext)
        {
            var noteType = HistoricalTestHelper.CreateDatabaseNoteType();
            var worker   = HistoricalTestHelper.CreateDatabaseWorker();
            var caseNote = HistoricalTestHelper.CreateDatabaseCaseNote(createdWorker: worker, noteType: noteType);

            socialCareContext.HistoricalWorkers.Add(worker);
            socialCareContext.HistoricalCaseNotes.Add(caseNote);
            socialCareContext.SaveChanges();

            return(new HistoricalCaseNote
            {
                CreatedBy = $"{worker.FirstNames} {worker.LastNames}",
                CreatedByWorker = caseNote.CreatedByWorker,
                Id = caseNote.Id,
                LastUpdatedBy = caseNote.LastUpdatedBy,
                Note = caseNote.Note,
                PersonId = caseNote.PersonId,
                Title = caseNote.Title,
                CreatedOn = caseNote.CreatedOn,
                NoteType = noteType.Type,
                HistoricalNoteType = noteType
            });
        }