Esempio n. 1
0
 public MangaService(AnimeContext animeContext)
 {
     db = animeContext;
     db.Genres.Load();
     db.Pages.Load();
     db.Mangas.Load();
 }
Esempio n. 2
0
        public override bool IsUserInRole(string username, string roleName)
        {
            bool outputResult = false;

            // Находим пользователя
            using (AnimeContext _db = new AnimeContext())
            {
                try
                {
                    // Получаем пользователя
                    user user = (from u in _db.users
                                 where u.login == username
                                 select u).FirstOrDefault();
                    if (user != null)
                    {
                        // получаем роль
                        role userRole = _db.roles.Find(user.id_role);

                        //сравниваем
                        if (userRole != null && userRole.name == roleName)
                        {
                            outputResult = true;
                        }
                    }
                }
                catch
                {
                    outputResult = false;
                }
            }
            return(outputResult);
        }
Esempio n. 3
0
        public override string[] GetRolesForUser(string login)
        {
            string[] role = new string[] { };
            using (AnimeContext _db = new AnimeContext())
            {
                try
                {
                    // Получаем пользователя
                    user user = (from u in _db.users
                                 where u.login == login
                                 select u).FirstOrDefault();
                    if (user != null)
                    {
                        // получаем роль
                        role userRole = _db.roles.Find(user.id_role);

                        if (userRole != null)
                        {
                            role = new string[] { userRole.name };
                        }
                    }
                }
                catch
                {
                    role = new string[] { };
                }
            }
            return(role);
        }
Esempio n. 4
0
 public UserService(AnimeContext animeContext)
 {
     db = animeContext;
     db.Genres.Load();
     db.Studios.Load();
     db.Mangas.Load();
     db.Animes.Load();
 }
Esempio n. 5
0
        private List <Anime> GetAnimes()
        {
            AnimeContext ac = new AnimeContext();

            List <Anime> lista = new List <Anime>();

            ac.animes.ToList()
            .ForEach(p => lista.Add(p));

            return(lista);
        }
Esempio n. 6
0
        public GenreService(AnimeContext animeContext)
        {
            db = animeContext;

            /*var anime = new Anime()
             * {
             *  Name = "Test",
             *  ReleaseDate = DateTime.Now,
             *  Season = 1,
             *  Source = "TestSource",
             *  Status = "Finish",
             *  Studio = "TestStudio",
             *  Type = "TestType",
             *  CountEpisodes = 21
             * };
             * var genre = new Genre() { Id = 0, Name = "XXX" };
             * anime.Genres.Add(genre);
             * var testStudio = new Studio() { Id = 0, Name = "Google", Link = "google.com" };
             * anime.Voices.Add(testStudio);
             *
             * var manga = new Manga()
             * {
             *  Author = "TestAuthor",
             *  Name = "TestManga",
             *  ReleaseContinues = true,
             *  Translater = "Google Translate",
             *  Volume = 1
             * };
             * manga.Genres.Add(genre);
             *
             * var user = new User() { Login = "******", Password = "******" };
             * user.FavoritesAnime.Add(anime);
             * user.FavoritesManga.Add(manga);
             *
             * db.Animes.Add(anime);
             * db.Mangas.Add(manga);
             * db.Users.Add(user);
             *
             * db.SaveChanges();*/
        }
        private bool ValidateUser(string login, string password)
        {
            bool isValid = false;

            using (AnimeContext _db = new AnimeContext())
            {
                try
                {
                    user user = (from u in _db.users
                                 where u.login == login && u.pasword == password
                                 select u).FirstOrDefault();

                    if (user != null)
                    {
                        isValid = true;
                    }
                }
                catch
                {
                    isValid = false;
                }
            }
            return(isValid);
        }
 public TranslationsController(AnimeContext context)
 {
     _context = context;
 }
 public AnimesController(AnimeContext context)
 {
     _context = context;
 }
Esempio n. 10
0
 public StudioService(AnimeContext animeContext)
 {
     db = animeContext;
 }
Esempio n. 11
0
 public AnimeController(AnimeContext context, IPlayer player)
 {
     _context = context;
     _player  = player;
 }
Esempio n. 12
0
        private async Task OnFavorite()
        {
            //TODO: o usuário pode escolher desativar pela tela de FavoritedView e AnimeSpecsView as notificações
            string lang         = default;
            var    bdCollection = App.liteDB.GetCollection <FavoritedAnime>();

            var taskResult = Task.Run(async() =>
            {
                if (bdCollection.Exists(p => p.Anime.MalId == AnimeContext.Anime.MalId))
                {
                    AnimeContext.IsFavorited = false;

                    bdCollection.Delete(AnimeContext.Anime.MalId);
                    lang = Lang.Lang.RemovedFromFavorite;
                }
                else
                {
                    AnimeContext.IsFavorited    = true;
                    AnimeContext.LastUpdateDate = DateTime.Today;

                    AnimeContext.NextStreamDate = await AnimeContext.NextEpisodeDateAsync();

                    int uniqueId = 0;

                    if (bdCollection.Count() > 0)
                    {
                        uniqueId = bdCollection.Max(p => p.UniqueNotificationID);

                        if (uniqueId == int.MaxValue)
                        {
                            uniqueId = 0;
                        }
                        else if (uniqueId < int.MaxValue)
                        {
                            uniqueId += 1;
                        }
                    }

                    AnimeContext.UniqueNotificationID = uniqueId;

                    AnimeContext.CanGenerateNotifications = AnimeContext.Anime.Airing && AnimeContext.NextStreamDate != null;

                    bdCollection.Upsert(AnimeContext.Anime.MalId, AnimeContext);
                    lang = Lang.Lang.AddedToFavorite;
                }

                if (OtherViewModelFunc != null)
                {
                    //atualiza a coleção observável de CatalogueViewModel
                    await OtherViewModelFunc.Invoke();
                }
            });


            await taskResult;

            DependencyService.Get <IToast>().MakeToastMessageShort(lang);

#if DEBUG
            Console.WriteLine("Animes favoritados no momento");
            foreach (var anime in bdCollection.FindAll())
            {
                Console.WriteLine(anime.Anime.Title);
            }
#endif
        }
Esempio n. 13
0
 public UsersController(AnimeContext context)
 {
     _context = context;
 }
Esempio n. 14
0
 public AnimesController(AnimeContext context)
 {
     DB = new AnimeContext(context);
 }