Example #1
0
        public void NoteAutoMap_EntityToDatabase_SuccessfulMapping()
        {
            Note note = new Note()
            {
                Id        = NOTE_ID,
                CreatedBy = CREATED_BY_ID,
                CreatedOn = DateTime.Now,
                //Contacts = (IList<Contact>)NoteMockData.GetMockNoteswithSetups(mockRepository, 2),
                //Tags = (ICollection<Tag>)NoteMockData.GetMockNoteTagsWithSetups(mockRepository, 2)
            };

            NotesDb notesDb = Mapper.Map <Note, NotesDb>(note);

            Assert.AreEqual(notesDb.NoteID, note.Id);
            Assert.AreEqual(notesDb.NoteDetails, note.Details);
        }
Example #2
0
        public void NoteAutoMAp_DatabaseToEntities_SuccessfulMapping()
        {
            NotesDb notesDb = new NotesDb()
            {
                NoteID      = NOTE_ID,
                NoteDetails = "Sample Note",
                CreatedBy   = CREATED_BY_ID,
                CreatedOn   = DateTime.Now
                              //Contacts = (ICollection<ContactsDb>)NoteMockData.GetMockNoteswithSetups(mockRepository, 2),
                              //Tags = (IList<TagsDb>)NoteMockData.GetMockNoteTagsWithSetups(mockRepository, 2)
            };

            Note note = Mapper.Map <NotesDb, Note>(notesDb);

            Assert.AreEqual(note.Id, notesDb.NoteID);
            Assert.AreEqual(note.Details, notesDb.NoteDetails);
        }
Example #3
0
 public NotesController(NotesDb database)
 {
     _database = database;
 }
Example #4
0
        public void Configure(IApplicationBuilder application, IWebHostEnvironment environment, NotesDb database)
        {
            if (_secrets.SeedData)
            {
                database.Database.EnsureDeleted();
                database.Database.EnsureCreated();
            }

            if (environment.IsDevelopment())
            {
                application.UseDeveloperExceptionPage();
            }
            else
            {
                application.UseHttpsRedirection();
            }

            application
            .UseCors(AllowSpecificOrigins)
            .UseFileServer(new FileServerOptions
            {
                FileProvider            = new PhysicalFileProvider(Path.Combine(Directory.GetCurrentDirectory(), "../Notes.Client")),
                RequestPath             = "/client",
                EnableDirectoryBrowsing = true
            })
            .UseSwagger()
            .UseSwaggerUI(c =>
            {
                c.SwaggerEndpoint("/swagger/v1/swagger.json", _apiInfo.Title);
            })
            .UseRouting()
            .UseAuthentication()
            .UseAuthorization()
            .UseEndpoints(endpoints => endpoints.MapControllers());
        }
Example #5
0
 public AnswersController(NotesDb database, Secrets secrets)
 {
     _database = database;
     _secrets  = secrets;
 }
 public BasicAuthenticationHandler(IOptionsMonitor <AuthenticationSchemeOptions> options, ILoggerFactory logger, UrlEncoder encoder, ISystemClock clock, NotesDb database)
     : base(options, logger, encoder, clock)
 {
     _database = database;
 }