/// <summary> /// obtains the challenge detail /// </summary> /// <param name="mod">identifier of module</param> /// <param name="id">identifier of section</param> /// <param name="sectionId">seccion del molulo</param> /// <returns>returns the result to action</returns> public ActionResult Detail(int mod, int id, int?sectionId) { ContentManagement objcontentman = new ContentManagement(SessionCustom, HttpContext); ContentRepository objcontent = new ContentRepository(SessionCustom); SuccessStoryRepository objSuccessStory = new SuccessStoryRepository(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); TagFacade tagFacade = new TagFacade(); objtemplate.Entity.Type = 0; objSuccessStory.Entity.ContentId = objfiles.Entity.ContentId = objcomment.Entity.ContentId = objcontent.Entity.ContentId = id; objSuccessStory.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 SuccessStoryModel() { UserPrincipal = this.CustomUser, ColModul = CustomMemberShipProvider.GetModuls(this.CustomUser.UserId, this.SessionCustom, HttpContext), Module = this.Module, ListFiles = objfiles.GetAllReadOnly(), SuccessStory = objSuccessStory.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, Tags = tagFacade.GetAll().Select(t => new SelectListItem { Text = t.Name, Value = t.TagId.ToString() }) })); }
public ActionResult Create(SuccessStoryModel model, HttpPostedFileBase contentImage, HttpPostedFileBase contentCoverImage, List <string> videoyoutube, string existingTags, string newTags) { SuccessStoryRepository objSuccessStory = new SuccessStoryRepository(this.SessionCustom); ContentManagement objcontent = new ContentManagement(this.SessionCustom, HttpContext); try { objcontent.ContentImage = contentImage; objcontent.ContentCoverImage = contentCoverImage; objcontent.CollVideos = videoyoutube; this.SessionCustom.Begin(); model.IContent.LanguageId = CurrentLanguage.LanguageId; objcontent.ContentInsert(model.IContent, 4); objSuccessStory.Entity = model.SuccessStory; objSuccessStory.Entity.ExistingTags = !string.Empty.Equals(existingTags) ? existingTags : null; objSuccessStory.Entity.NewTags = !string.Empty.Equals(newTags) ? newTags : null; if (objSuccessStory.Entity.ContentId != null) { objSuccessStory.Update(); this.InsertAudit("Update", this.Module.Name + " -> " + model.IContent.Name); } else { if (!string.IsNullOrEmpty(Request.Form["TempFiles"])) { string[] files = Request.Form["TempFiles"].Split(','); if (files.Length > 0) { if (!Directory.Exists(Path.Combine(Server.MapPath("~"), @"Files\" + objcontent.ObjContent.ContentId + @"\"))) { Directory.CreateDirectory(Path.Combine(Server.MapPath("~"), @"Files\" + objcontent.ObjContent.ContentId + @"\")); } } foreach (var item in files) { string filep = Path.Combine(Server.MapPath("~"), @"Files\Images\" + Path.GetFileName(item)); if (System.IO.File.Exists(filep)) { string filedestin = Path.Combine(Server.MapPath("~"), @"Files\Images\" + Path.GetFileName(item)); System.IO.File.Move(filep, Path.Combine(Server.MapPath("~"), @"Files\" + objcontent.ObjContent.ContentId + @"\" + Path.GetFileName(item))); } } } objSuccessStory.Entity.ContentId = objcontent.ObjContent.ContentId; objSuccessStory.Insert(); this.InsertAudit("Insert", this.Module.Name + " -> " + model.IContent.Name); } this.SessionCustom.Commit(); if (model.PostulateId != null) { SuccessStoryPostulateFacade dbpostulate = new SuccessStoryPostulateFacade(); Domain.Entities.Generic.SuccessStoryPostulate postulate = dbpostulate.GetById(model.PostulateId.Value, this.CurrentLanguage.LanguageId.Value); postulate.SuccessStoryId = objcontent.ObjContent.ContentId; postulate.State = (int)Domain.Entities.Enums.SuccessStoryPostulateStateEnum.Published; if (dbpostulate.Update(postulate)) { string domainUrl = string.Format("/SuccessStory/Story/{0}", objcontent.ObjContent.ContentId.Value); this.SendUserNotification(postulate.UserId, domainUrl, objcontent.ObjContent.ContentId.Value); } this.InsertAudit("Update Postulate", this.Module.Name + " -> " + model.IContent.Name); } } catch (Exception ex) { SessionCustom.RollBack(); Utils.InsertLog( this.SessionCustom, "Error" + this.Module.Name, ex.Message + " " + ex.StackTrace); } if (Request.Form["GetOut"] == "0") { return(this.RedirectToAction("Index", "Content", new { mod = Module.ModulId })); } else { return(this.RedirectToAction("Detail", "SuccessStory", new { mod = Module.ModulId, id = objSuccessStory.Entity.ContentId })); } }
/// <summary> /// Bind the context and the session with the content /// </summary> /// <param name="context">Context page</param> /// <param name="session">Session object</param> /// <param name="id">Content ID</param> /// <param name="userId">current user ID</param> public void Bind(HttpContextBase context, ISession session, int?id, int?userId, int?LanguajeId) { SuccessStoryRepository SuccessStoryrepository = new SuccessStoryRepository(session); this.CollSuccessStory = SuccessStoryrepository.GetAllFrontEnd(LanguajeId); }