Exemplo n.º 1
0
        /// <summary>
        /// gets the home of BlogEntry module
        /// </summary>
        /// <returns>returns the result to action</returns>
        public ActionResult Index()
        {
            SetLabel();
            Business.Services.CustomPrincipal currentUserInfo = (Business.Services.CustomPrincipal)User;
            if (Utils.IsBlogAdmin(currentUserInfo.UserId))
            {
                int mod       = 54;
                int sectionId = 34;

                ContentManagement  objcontentman = new ContentManagement(this.SessionCustom, HttpContext);
                SectionRepository  objsection    = new SectionRepository(this.SessionCustom);
                TemplateRepository objtemplate   = new TemplateRepository(this.SessionCustom);
                objtemplate.Entity.Type = 0;

                return(this.View(new BlogEntryModel()
                {
                    UserPrincipal = this.CustomUser,
                    Module = this.Module,
                    ColModul = CustomMemberShipProvider.GetModuls(this.CustomUser.UserId, this.SessionCustom, HttpContext),
                    Templates = objtemplate.GetAll().Select(t => t.TemplateId),
                    DeepFollower = Business.Utils.GetDeepFollower(objsection.GetAll(), sectionId),
                    IContent = new Domain.Entities.Content()
                    {
                        ModulId = mod,
                        SectionId = sectionId
                    },
                    CurrentLanguage = this.CurrentLanguage
                }));
            }

            return(null);
        }
Exemplo n.º 2
0
        /// <summary>
        /// obtains the challenge detail
        /// </summary>
        /// <param name="id">identifier of section</param>
        /// <returns>returns the result to action</returns>
        public ActionResult Detail(int id)
        {
            Business.Services.CustomPrincipal currentUserInfo = (Business.Services.CustomPrincipal)User;
            if (Utils.IsBlogAdmin(currentUserInfo.UserId))
            {
                ContentManagement    objcontentman = new ContentManagement(SessionCustom, HttpContext);
                ContentRepository    objcontent    = new ContentRepository(SessionCustom);
                BlogEntryRepository  objblogentry  = new BlogEntryRepository(SessionCustom);
                FileattachRepository objfiles      = new FileattachRepository(SessionCustom);
                TagRepository        objtag        = new TagRepository(SessionCustom);
                SectionRepository    objsection    = new SectionRepository(SessionCustom);
                TemplateRepository   objtemplate   = new TemplateRepository(SessionCustom);
                CommentRepository    objcomment    = new CommentRepository(SessionCustom);

                objtemplate.Entity.Type = 0;

                objblogentry.Entity.ContentId           =
                    objfiles.Entity.ContentId           =
                        objcomment.Entity.ContentId     =
                            objcontent.Entity.ContentId = id;

                objblogentry.LoadByKey();
                objcontent.LoadByKey();

                int totalComments = 0;
                List <CommentsPaging> comments = objcomment.CommentsPagingContent(0, 50, out totalComments, id);
                ViewBag.TotalComments = totalComments;

                IEnumerable <Tag> SelectedTags = objtag.GetTagbycontent(id);
                this.ViewBag.SelectedTags = string.Join("|", SelectedTags.Select(t => t.TagId));
                this.ViewBag.NewsTags     = string.Empty;

                return(this.View(
                           "Index",
                           new BlogEntryModel()
                {
                    UserPrincipal = this.CustomUser,
                    ColModul = CustomMemberShipProvider.GetModuls(this.CustomUser.UserId, this.SessionCustom, HttpContext),
                    Module = this.Module,
                    ListFiles = objfiles.GetAllReadOnly(),
                    BlogEntry = objblogentry.Entity,
                    IContent = objcontent.Entity,
                    Templates = objtemplate.GetAll().Select(t => t.TemplateId),
                    ListContent = objcontent.GetContentRelation(CurrentLanguage.LanguageId.Value),
                    ListTags = SelectedTags,
                    DeepFollower = Business.Utils.GetDeepFollower(objsection.GetAll(), objcontent.Entity.SectionId.Value),
                    CurrentLanguage = this.CurrentLanguage,
                    ListComments = comments
                }));
            }

            return(null);
        }
Exemplo n.º 3
0
        public ActionResult Create(BlogEntryModel model, string contentImage, List <string> videoyoutube)
        {
            Business.Services.CustomPrincipal currentUserInfo = (Business.Services.CustomPrincipal)User;
            if (Utils.IsBlogAdmin(currentUserInfo.UserId))
            {
                BlogEntryRepository objblogentry = new BlogEntryRepository(this.SessionCustom);
                ContentManagement   objcontent   = new ContentManagement(this.SessionCustom, HttpContext);

                try
                {
                    model.IContent.Template = "BlogEntry";
                    model.IContent.Widget   = false;
                    model.IContent.Private  = false;
                    model.IContent.Active   = true;
                    model.IContent.Image    = contentImage;

                    objcontent.CollVideos = videoyoutube;
                    this.SessionCustom.Begin();

                    model.IContent.LanguageId = 2;
                    objcontent.ContentInsert(model.IContent, 4);
                    objblogentry.Entity = model.BlogEntry;
                    if (objblogentry.Entity.ContentId != null)
                    {
                        objblogentry.Update();
                        this.InsertAudit("Update", this.Module.Name + " -> " + model.IContent.Name);
                    }
                    else
                    {
                        objblogentry.Entity.ContentId = objcontent.ObjContent.ContentId;
                        objblogentry.Insert();

                        this.InsertAudit("Insert", this.Module.Name + " -> " + model.IContent.Name);
                    }

                    string serverMap = Server.MapPath("~");
                    string origin    = serverMap + @"\resources\temporal\blog\" + contentImage;
                    if (System.IO.File.Exists(origin))
                    {
                        if (!System.IO.Directory.Exists(serverMap + @"\files\" + objblogentry.Entity.ContentId))
                        {
                            System.IO.Directory.CreateDirectory(serverMap + @"\files\" + objblogentry.Entity.ContentId);
                        }

                        System.IO.File.Move(origin, serverMap + @"\files\" + objblogentry.Entity.ContentId + @"\" + contentImage);
                    }

                    this.SessionCustom.Commit();
                    ViewBag.Result = true;
                }
                catch (Exception ex)
                {
                    SessionCustom.RollBack();
                    Utils.InsertLog(
                        this.SessionCustom,
                        "Error" + this.Module.Name,
                        ex.Message + " " + ex.StackTrace);
                    ViewBag.Result = false;
                }

                return(this.View("index", model));
            }

            return(null);
        }