Ejemplo n.º 1
0
 public static IReserve GetReserveInstace(string userId, BookIds book)
 {
     return(new Reserve
     {
         UserId = userId,
         BookIds = book
     });
 }
Ejemplo n.º 2
0
 public void DeleteBookIds(BookIds bookId)
 {
     bookidsRepository.Delete(bookId);
 }
Ejemplo n.º 3
0
 public void UpdateBookId(BookIds bookId)
 {
     bookidsRepository.Update(bookId);
 }
Ejemplo n.º 4
0
 public void AddBookId(BookIds book)
 {
     bookidsRepository.Add(book);
 }
Ejemplo n.º 5
0
        protected override void Seed(LibraryEntities context)
        {
            //AOXzk3nA3Vobf7vpv703kJt9iMD76UzV6lwaCHufQ4HPo/3N0F2HJphqoclambmXmw== burak1234
            try
            {
                var userIds = new Dictionary <string, string>();
                var users   = new List <ApplicationUser>
                {
                    new ApplicationUser
                    {
                        UserName      = "******",
                        PasswordHash  = "AOXzk3nA3Vobf7vpv703kJt9iMD76UzV6lwaCHufQ4HPo/3N0F2HJphqoclambmXmw==",
                        Email         = "*****@*****.**",
                        SecurityStamp = Guid.NewGuid().ToString()
                    },
                    new ApplicationUser
                    {
                        UserName      = "******",
                        PasswordHash  = "AOXzk3nA3Vobf7vpv703kJt9iMD76UzV6lwaCHufQ4HPo/3N0F2HJphqoclambmXmw==",
                        Email         = "*****@*****.**",
                        SecurityStamp = Guid.NewGuid().ToString()
                    }
                };

                foreach (var user in users)
                {
                    context.Users.Add(user);
                    context.SaveChanges();
                    userIds.Add(user.Email, user.Id);
                }
                var store   = new RoleStore <IdentityRole>(context);
                var manager = new RoleManager <IdentityRole>(store);
                var role    = new IdentityRole {
                    Name = "Admin"
                };
                manager.Create(role);

                var userStore   = new UserStore <ApplicationUser>(context);
                var userManager = new UserManager <ApplicationUser>(userStore);
                userManager.AddToRole(userIds["*****@*****.**"], "Admin");
                context.SaveChanges();

                var books = new List <Books>
                {
                    new Books
                    {
                        BookTitle = "Gölgeler",
                        Isbn      = "9786050952544",
                        Authors   = new List <Authors>
                        {
                            new Authors
                            {
                                AuthorName = "Zülfü Livaneli"
                            }
                        },
                        PublishYear = "2018",
                        BookCount   = 10
                    },
                    new Books
                    {
                        BookTitle = "Sabahattin Ali Üç Roman",
                        Isbn      = "9789750842429",
                        Authors   = new List <Authors>
                        {
                            new Authors
                            {
                                AuthorName = "Sabahattin Ali"
                            }
                        },
                        PublishYear = "2018",
                        BookCount   = 10
                    },
                    new Books
                    {
                        BookTitle = "Sen Gittin Ya Ben Çok Güzelleştim",
                        Isbn      = "9786053114253",
                        Authors   = new List <Authors>
                        {
                            new Authors
                            {
                                AuthorName = "Nilgün Bodur"
                            }
                        },
                        PublishYear = "2018",
                        BookCount   = 10
                    },
                };
                books.ForEach(book => context.Books.Add(book));
                context.SaveChanges();
                foreach (var book in books)
                {
                    for (int i = 0; i < book.BookCount; i++)
                    {
                        var newBookId = new BookIds
                        {
                            BookId = Guid.NewGuid().ToString(),
                            Isbn   = book.Isbn
                        };
                        context.BookIds.Add(newBookId);
                    }
                }

                context.SaveChanges();
            }
            catch
            {
            }
        }