コード例 #1
0
        protected override void Seed(AlbumStoreContext context)
        {
            var genres = new List <Genre>()
            {
                new Genre {
                    Name = "Rock", Description = "Rock music"
                },
                new Genre {
                    Name = "Pop", Description = "Pop music"
                }
            };

            genres.ForEach(s => context.Genres.Add(s));
            context.SaveChanges();

            //var manager = new ApplicationUserManager(new UserStore<ApplicationUser>(context.Get<SchoolContext>()));
            var userStore   = new UserStore <ApplicationUser>(context);
            var userManager = new UserManager <ApplicationUser>(userStore);
            var user        = new ApplicationUser()
            {
                UserName             = "******",
                Email                = "*****@*****.**",
                EmailConfirmed       = false,
                PhoneNumberConfirmed = false,
                TwoFactorEnabled     = false,
                LockoutEnabled       = true
            };

            if (!userManager.Users.Any(m => m.UserName.Equals("*****@*****.**")))
            {
                userManager.Create(user, "Password1-");
            }

            base.Seed(context);
        }
コード例 #2
0
        public AlbumDto GetDto(long id)
        {
            _albumStoreContext.ChangeTracker.LazyLoadingEnabled = true;

            using (var context = new AlbumStoreContext())
            {
                var album = context.Album
                            .Include(a => a.AlbumInfo)
                            .SingleOrDefault(b => b.Id == id);

                if (album != null)
                {
                    return(AlbumDtoMapper.MapToDto(album));
                }

                return(null);
            }
        }
コード例 #3
0
            public BrandsController(AlbumStoreContext context)
            {
                db = context;

                if (db.Singers.Count() == 0)
                {
                    Singer EdSheeran = new Singer {
                        Name = "EdSheeran", Birthdate = "10.10.2000"
                    };
                    Singer Adelle = new Singer {
                        Name = "Adelle", Birthdate = "15.01.1999"
                    };
                    Singer MJaskon = new Singer {
                        Name = "MichaleJackson", Birthdate = "07.02.1989"
                    };
                    Singer NBHD = new Singer {
                        Name = "The Neighbourhood", Birthdate = "09.10.1985"
                    };
                    if (!context.Singers.Any())
                    {
                        context.Singers.AddRange(EdSheeran, Adelle, MJaskon, NBHD);
                        context.SaveChanges();
                    }

                    if (!context.Albums.Any())
                    {
                        context.Albums.AddRange(
                            new Album
                        {
                            Singer = EdSheeran,
                            Date   = "14.02.15",
                            Name   = "Love"
                        },
                            new Album
                        {
                            Singer = Adelle,
                            Name   = "heart",
                            Date   = "18.09.19"
                        },
                            new Album
                        {
                            Singer = MJaskon,
                            Name   = "Sing",
                            Date   = "09.08.17"
                        },
                            new Album
                        {
                            Singer = EdSheeran,
                            Name   = "Dance",
                            Date   = "2.12.18"
                        },
                            new Album
                        {
                            Singer = NBHD,
                            Name   = "Grey",
                            Date   = "03.02.2018"
                        },
                            new Album
                        {
                            Singer = NBHD,
                            Name   = "Black",
                            Date   = "18.08.2015"
                        }
                            );
                        context.SaveChanges();
                    }
                }
            }
コード例 #4
0
 public AlbumDataManager(AlbumStoreContext albumStoreContext)
 {
     _albumStoreContext = albumStoreContext;
 }
コード例 #5
0
 public PerfumesController(AlbumStoreContext context)
 {
     db = context;
 }