Пример #1
0
 static public void RemoveData(FierceStukCloudDbContext context)
 {
     context.Songs.RemoveRange(context.Songs.AsEnumerable());
     context.Authors.RemoveRange(context.Authors.AsEnumerable());
     context.PlayLists.RemoveRange(context.PlayLists.AsEnumerable());
     context.SaveChanges();
 }
Пример #2
0
        public override Task OnConnectedAsync()
        {
            var user = _context.Users.FirstOrDefault(x => x.Login == Context.User.Identity.Name);

            if (Context.User.FindFirst("Device").Value == "PC")
            {
                user.ConnectionIdPC = Context.ConnectionId;
                user.StatusPC       = "Online";
            }
            else
            {
                user.ConnectionIdPhone = Context.ConnectionId;
                user.StatusPhone       = "Online";
            }

            _context.SaveChanges();

            return(base.OnConnectedAsync());
        }
Пример #3
0
        static public void CreateData(FierceStukCloudDbContext context)
        {
            PlayLists = PlayListsFactory();
            Authors   = AuthorsFactory();

            context.PlayLists.AddRange(PlayLists.AsEnumerable());
            context.Authors.AddRange(Authors.AsEnumerable());
            context.SaveChanges();

            var s1 = new Song()
            {
                Id = Guid.NewGuid(), Title = "title0"
            };

            s1.Authors.Add(Authors[0]);
            //s1.DbAuthors = new List<SongAuthor>()
            //{
            //    SongAuthorFactory(s1.Id, Authors[0].Id)
            //};


            var s2 = new Song()
            {
                Id = Guid.NewGuid(), Title = "title2"
            };

            s2.Authors.Add(Authors[0]);
            //s2.DbAuthors = new List<SongAuthor>()
            //{
            //    SongAuthorFactory(s2.Id, Authors[0].Id)
            //};

            Songs = new List <Song>();
            Songs.Add(s1);
            Songs.Add(s2);

            //PlayLists[0].DbSongs.Add(new SongPlayList() { Place = 0, PlayListId = PlayLists[0].Id, SongId = Songs[0].Id });
            PlayLists[0].Songs.Add(Songs[0]);

            context.Songs.Add(s1);
            context.Songs.Add(s2);
            context.SaveChanges();
        }