Exemple #1
0
 static public void ConfigureServices(string connectionString, IServiceCollection services)
 {
     services.AddDbContext <GuestbookDbContext>(options => options.UseSqlServer(connectionString))
     .AddTransient <EfGuestbookDbContext, GuestbookDbContext>()
     .AddTransient <IGuestbookRepository, GuestbookRepository>()
     .AddTransient <IGuestbookManagement, GuestbookManagement>()
     // Here we get a new entry with default constructor
     .AddTransient <IGuestbookEntry, GuestbookEntry>()
     .AddTransient <IGuestbook, Guestbook>((contex) =>
     {
         // And here we are using our guestbook factory
         Guestbook entity = Guestbook.CreateGuestbook("<unknown diary>");
         return(entity);
     });
 }
Exemple #2
0
        public GuestbookDto Add(string sName)
        {
            IGuestbook newBook = Guestbook.CreateGuestbook(sName);

            newBook = mGuestbookRepository.Add(newBook); // engine code with storage

            //Mapping domain object to ui object
            GuestbookDto newBookDto = new GuestbookDto
            {
                Name = newBook.Name,
                Id   = newBook.Id
            };

            return(newBookDto);
        }