Exemplo n.º 1
0
        public ActionResult Edit(Int32 id)
        {
            if (Request.Cookies["MagazineId"].Value == null)
            {
                SetMessage("Lo sentimos, ha ocurrido un error. Inténtelo de nuevo.", BootstrapAlertTypes.Danger); return(RedirectToAction("Index", "Magazines"));
            }
            int magId = Int32.Parse(Request.Cookies["MagazineId"].Value);

            var user     = UserService.GetCurrentUser();
            var relation = UserService.UserInMagazine(magId, user.UserId);

            if (!relation || !ModelState.IsValid)
            {
                return(RedirectToAction("Index", "Magazines"));
            }

            var category = MagazineService.GetCategoryById(id);

            if (category == null)
            {
                SetMessage("No se encontró la categoría.", BootstrapAlertTypes.Danger);
                return(RedirectToAction("Index", "Magazines"));
            }

            ViewBag.MagazineId = new SelectList(MagazineService.GetCurrentUserMagazines(), "MagazineId", "Title", category.MagazineId);
            var categories = MagazineService.GetCategoriesByMagazineId(magId);

            ViewBag.ParentCategory = category.ParentCategoryId ?? null;
            var model = new CategoryViewModel
            {
                Name              = category.Name,
                CategoryId        = category.CategoryId,
                LogoImage         = category.Image,
                MagazineId        = category.MagazineId,
                Permalink         = category.Permalink,
                ParentsCategories = categories
            };

            return(View(model));
        }
Exemplo n.º 2
0
        public ActionResult Index()
        {
            var rol       = UserService.GetRolUser();
            var magazines = MagazineService.GetCurrentUserMagazines();

            if (RoleService.IsUserInRole(UserEmail, "SuperAdmin"))
            {
                List <int> termsList = new List <int>();
                foreach (var item in magazines)
                {
                    var Count = InfluencerService.GetVisitsByMagazine(item.MagazineId);
                    termsList.Add(Count);
                }
            }

            var model = new MagazinesIndexViewModel
            {
                MagazinesList = magazines,
            };

            ViewBag.CurrenUser = Session["currentUser"];
            return(View(model));
        }
Exemplo n.º 3
0
        // GET: Clone
        public ActionResult Index()
        {
            if (Request.Cookies["MagazineId"].Value == null)
            {
                SetMessage("Lo sentimos, ha ocurrido un error. Inténtelo de nuevo.", BootstrapAlertTypes.Danger); return(RedirectToAction("Index", "Magazines"));
            }
            int magId = Int32.Parse(Request.Cookies["MagazineId"].Value);

            var getLocation   = MagazineService.GetCurrentMagazine(magId);
            var GetNearlyMags = MagazineService.GetNearlyMagazines(getLocation.CityId);

            List <NearlyNews> ListOfNews = new List <NearlyNews>();

            foreach (var item in GetNearlyMags)
            {
                var getNews = MagazineService.GetPublicNewsByMagazineId(item.MagazineId, 1);
                if (getNews.Any())
                {
                    ListOfNews.Add(new NearlyNews
                    {
                        MagazineId   = getNews[0].Category.MagazineId,
                        MagazineName = getNews[0].Category.Magazine.Title,
                        NewsList     = getNews
                    });
                }
            }

            var magazines = MagazineService.GetCurrentUserMagazines();

            ViewBag.MagazineId = magId;
            ViewBag.Magazines  = JsonConvert.SerializeObject(magazines, Formatting.None, new JsonSerializerSettings()
            {
                ReferenceLoopHandling = ReferenceLoopHandling.Ignore
            });
            return(View(ListOfNews));
        }
Exemplo n.º 4
0
        // GET: Admin
        public ActionResult Index()
        {
            var getMagazines = MagazineService.GetCurrentUserMagazines();

            return(View());
        }
Exemplo n.º 5
0
        public ActionResult MyNews()
        {
            if (Request.Cookies["MagazineId"].Value == null)
            {
                SetMessage("Lo sentimos, ha ocurrido un error. Inténtelo de nuevo.", BootstrapAlertTypes.Danger); return(RedirectToAction("Index", "Magazines"));
            }

            var id = Int32.Parse(Request.Cookies["MagazineId"].Value);

            var user     = UserService.GetCurrentUser();
            var relation = UserService.UserInMagazine(id, user.UserId);

            if (!relation || !ModelState.IsValid)
            {
                return(RedirectToAction("Index", "Magazines"));
            }

            var news = MagazineService.GetNewsByMagazineId(id);

            var cats = MagazineService.GetCategoriesByMagazineId(id);

            if (cats.Count == 0)
            {
                return(RedirectToAction("CreateCategory", "Wizard", new { id = id }));
            }
            var mags = MagazineService.GetCurrentUserMagazines();
            List <MagazineToCLone> magList = new List <MagazineToCLone>();

            foreach (var item in mags)
            {
                var magModel = new MagazineToCLone()
                {
                    MagazineId = item.MagazineId,
                    Title      = item.Title
                };
                magList.Add(magModel);
            }
            //var top10Influencers = MagazineService.GetTop10Influencers(id);

            var model = new MagazineIndexViewModel
            {
                MagazineId = id,
                Categories = cats,
                //Top10Influencers = top10Influencers,
                News = news
            };

            //var magazines = MagazineService.GetCurrentUserMagazines();
            //var allCats = new List<Category>();
            //foreach (var item in magazines)
            //{
            //    var items = MagazineService.GetCategoriesByMagazineId(item.MagazineId);
            //    foreach (var a in items) { allCats.Add(a); }
            //}

            //ViewBag.Visits = JsonConvert.SerializeObject(newsAndVisits.VisitCounts);
            //ViewBag.Categories = JsonConvert.SerializeObject(allCats, Formatting.None, new JsonSerializerSettings() { ReferenceLoopHandling = ReferenceLoopHandling.Ignore });
            ViewBag.Magazines = JsonConvert.SerializeObject(magList, Formatting.Indented, new JsonSerializerSettings()
            {
                ReferenceLoopHandling = ReferenceLoopHandling.Ignore
            });

            return(View(model));
        }