public ActionResult verblog(long?blogID)
        {
            if (Session["USER_ID"] != null)
            {
                if (blogID != null)
                {
                    long userId       = (long)Session["USER_ID"];
                    long communityAct = Convert.ToInt64(Session["CURRENT_COMU"]);
                    List <ShowMessage> pubMessageList = ep.GetChatMessages(userId);
                    user             curUser          = entities.users.Find(userId);
                    blog             blog             = entities.blogs.Find(blogID);
                    verblogViewModel viewModel        = new verblogViewModel();
                    viewModel.side_menu     = "comunicaciones";
                    viewModel.side_sub_menu = "comunicaciones";

                    viewModel.curUser         = curUser;
                    viewModel.viewBlog        = blog;
                    viewModel.Content         = blogID.ToString();
                    viewModel.blogID          = Convert.ToInt64(blogID);
                    viewModel.blogcommentList = entities.blogcomments.Where(m => m.blog_id == blogID).ToList();
                    viewModel.pubTaskList     = ep.GetNotifiTaskList(userId);
                    viewModel.pubMessageList  = pubMessageList;
                    viewModel.messageCount    = ep.GetUnreadMessageCount(pubMessageList);
                    return(View(viewModel));
                }
                else
                {
                    return(Redirect(Url.Action("NotFound", "Error")));
                }
            }
            else
            {
                return(Redirect(ep.GetLogoutUrl()));
            }
        }
 public ActionResult verblog(long?blogID)
 {
     if (Session["USER_ID"] != null)
     {
         if (Session["CURRENT_COMU"] != null)
         {
             if (blogID != null)
             {
                 long communityAct = Convert.ToInt64(Session["CURRENT_COMU"]);
                 blog blog         = entities.blogs.Where(x => x.id == blogID && x.community_id == communityAct || x.id == blogID && x.user.role == 3).FirstOrDefault();
                 if (blog != null)
                 {
                     try
                     {
                         long userId = (long)Session["USER_ID"];
                         List <ShowMessage> pubMessageList = ep.GetChatMessages(userId);
                         user             curUser          = entities.users.Find(userId);
                         verblogViewModel viewModel        = new verblogViewModel();
                         communityList                    = ep.GetCommunityList(userId);
                         viewModel.communityList          = communityList;
                         viewModel.side_menu              = "comunicaciones";
                         viewModel.side_sub_menu          = "comunicaciones_blog";
                         viewModel.document_category_list = entities.document_type.Where(x => x.community_id == communityAct).ToList();
                         viewModel.curUser                = curUser;
                         viewModel.viewBlog               = blog;
                         viewModel.Content                = blogID.ToString();
                         viewModel.blogID                 = Convert.ToInt64(blogID);
                         viewModel.blogcommentList        = entities.blogcomments.Where(m => m.blog_id == blogID).ToList();
                         viewModel.pubTaskList            = ep.GetNotifiTaskList(userId);
                         viewModel.pubMessageList         = pubMessageList;
                         viewModel.messageCount           = ep.GetUnreadMessageCount(pubMessageList);
                         return(View(viewModel));
                     }
                     catch (Exception ex)
                     {
                         return(Redirect(Url.Action("error", "control", new { area = "coadmin", Error = "Ver blog: " + ex.Message })));
                     }
                 }
                 else
                 {
                     return(Redirect(Url.Action("blog", "comunicaciones", new { area = "coadmin", Error = "No existe ese elemento" })));
                 }
             }
             else
             {
                 return(Redirect(Url.Action("blog", "comunicaciones", new { area = "coadmin" })));
             }
         }
         else
         {
             return(Redirect(Url.Action("blog", "comunicaciones", new { area = "coadmin", Error = "No permitido. Usted no administra ninguna comunidad. Comuníquese con el Webmaster..." })));
         }
     }
     else
     {
         return(Redirect(ep.GetLogoutUrl()));
     }
 }
Ejemplo n.º 3
0
        public ActionResult verblog(long?blogID)
        {
            if (Session["USER_ID"] != null)
            {
                if (Session["CURRENT_COMU"] != null)
                {
                    if (blogID != null)
                    {
                        long communityAct = Convert.ToInt64(Session["CURRENT_COMU"]);
                        blog blog         = entities.blogs.Where(x => x.id == blogID && x.community_id == communityAct).FirstOrDefault();
                        if (blog != null)
                        {
                            try
                            {
                                long userId = (long)Session["USER_ID"];
                                List <ShowMessage> pubMessageList = ep.GetChatMessages(userId);
                                user             curUser          = entities.users.Find(userId);
                                verblogViewModel viewModel        = new verblogViewModel();

                                titulosList             = ep.GetTitulosByTitular(userId);
                                listComunities          = ep.GetCommunityListByTitular(titulosList);
                                viewModel.communityList = listComunities;

                                viewModel.side_menu              = "comunicaciones";
                                viewModel.side_sub_menu          = "comunicaciones_verblog";
                                viewModel.document_category_list = entities.document_type.Where(x => x.community_id == communityAct).ToList();
                                viewModel.curUser         = curUser;
                                viewModel.Content         = blogID.ToString();
                                viewModel.viewBlog        = blog;
                                viewModel.blogID          = Convert.ToInt64(blogID);
                                viewModel.blogcommentList = entities.blogcomments.Where(m => m.blog_id == blogID).ToList();
                                viewModel.pubTaskList     = ep.GetNotifiTaskList(userId);
                                viewModel.pubMessageList  = pubMessageList;
                                viewModel.messageCount    = ep.GetUnreadMessageCount(pubMessageList);
                                return(View(viewModel));
                            }
                            catch (Exception ex)
                            {
                                return(Redirect(Url.Action("error", "control", new { Error = "Agregar comentario blog: ", ex.Message })));
                            }
                        }
                        else
                        {
                            return(Redirect(Url.Action("blog", "comunicaciones", new { Error = "No existe ese elemento" })));
                        }
                    }
                    else
                    {
                        return(Redirect(Url.Action("blog", "comunicaciones")));
                    }
                }
                else
                {
                    return(Redirect(Url.Action("blog", "comunicaciones", new { Error = "No puede ver el blog. Usted no pertenece ninguna comunidad" })));
                }
            }
            else
            {
                return(Redirect(ep.GetLogoutUrl()));
            }
        }