Example #1
0
        public JsonResult Crear(int ideaId, string text)
        {
            bool result        = false;
            int  currentUserId = ((CustomPrincipal)User).UserId;
            CommentRepository commentRepository = new CommentRepository(SessionCustom);

            commentRepository.Entity.Text         = text;
            commentRepository.Entity.IdeaId       = ideaId;
            commentRepository.Entity.Active       = true;
            commentRepository.Entity.UserId       = currentUserId;
            commentRepository.Entity.Creationdate = DateTime.Now;
            int commentId = Convert.ToInt32(commentRepository.Insert());

            result = true;

            IdeaRepository idea = new IdeaRepository(SessionCustom);

            idea.Entity.IdeaId = ideaId;
            idea.LoadByKey();
            bool update = idea.Entity.UserId.Value == commentRepository.Entity.UserId.Value ? true : false;

            if (idea.Entity.UserId.Value != commentRepository.Entity.UserId.Value)
            {
                Utils.SetUserRewardAction(commentRepository.Entity.UserId.Value, RewardAction.UserActionType.CommentIdea, 21, 21, this.SessionCustom, ControllerContext.HttpContext, true, this.CurrentLanguage);
                Utils.SetUserRewardAction(idea.Entity.UserId.Value, RewardAction.UserActionType.ReciveComment, 21, int.MaxValue, this.SessionCustom, ControllerContext.HttpContext, update, this.CurrentLanguage);
                Business.Utilities.Notification.NewNotification(idea.Entity.UserId.Value, null, Domain.Entities.Basic.SystemNotificationType.RECEIVE_IDEA_COMMENT, currentUserId, string.Concat("/", idea.Entity.Friendlyurlid), idea.Entity.ContentId, commentId, null, null, null, this.SessionCustom, this.HttpContext, this.CurrentLanguage);
            }
            else
            {
                Utils.SetUserRewardAction(commentRepository.Entity.UserId.Value, RewardAction.UserActionType.CommentIdea, 21, 0, this.SessionCustom, ControllerContext.HttpContext, true, this.CurrentLanguage);
                Utils.SetUserRewardAction(idea.Entity.UserId.Value, RewardAction.UserActionType.ReciveComment, 21, 0, this.SessionCustom, ControllerContext.HttpContext, update, this.CurrentLanguage);
            }

            // hilo notificaciones de usuarios relacionados
            Business.Utilities.Notification.StartRelatedContentUser(commentRepository.Entity.UserId.Value, idea.Entity.IdeaId.Value, null, Domain.Entities.Basic.SystemNotificationType.RECEIVE_IDEA_RELATED_COMMENT, currentUserId, string.Concat("/", idea.Entity.Friendlyurlid), idea.Entity.ContentId, commentId, null, null, null, this.HttpContext, this.CurrentLanguage);

            if (idea.IsIdeaInTop10(idea.Entity.IdeaId.Value))
            {
                SystemNotificationRepository notification = new SystemNotificationRepository(SessionCustom);
                int count = notification.SystemNotificationCount(idea.Entity.UserId.Value, (int)Domain.Entities.Basic.SystemNotificationType.IDEA_TOP_10, idea.Entity.IdeaId.Value);
                if (count == 0)
                {
                    Business.Utilities.Notification.NewNotification(idea.Entity.UserId.Value, null, Domain.Entities.Basic.SystemNotificationType.IDEA_TOP_10, null, string.Concat("/", idea.Entity.Friendlyurlid), idea.Entity.ContentId, idea.Entity.IdeaId.Value, null, null, null, this.SessionCustom, this.HttpContext, this.CurrentLanguage);
                }
            }

            if (idea.IsIdeaInTop5Home(idea.Entity.IdeaId.Value))
            {
                SystemNotificationRepository notification = new SystemNotificationRepository(SessionCustom);
                int count = notification.SystemNotificationCount(idea.Entity.UserId.Value, (int)Domain.Entities.Basic.SystemNotificationType.POPULAR_IDEA_TOP_5, idea.Entity.IdeaId.Value);
                if (count == 0)
                {
                    Business.Utilities.Notification.NewNotification(idea.Entity.UserId.Value, null, Domain.Entities.Basic.SystemNotificationType.POPULAR_IDEA_TOP_5, null, string.Concat("/", idea.Entity.Friendlyurlid), idea.Entity.ContentId, idea.Entity.IdeaId.Value, null, null, null, this.SessionCustom, this.HttpContext, this.CurrentLanguage);
                }
            }

            Business.UserRelation.SaveRelationAction(((CustomPrincipal)User).UserId, idea.Entity.UserId.Value, commentId, "comment", this.SessionCustom);

            return(this.Json(new { result = result }));
        }
Example #2
0
        /// <summary>
        /// content relation process
        /// </summary>
        /// <param name="currentUserId">current user id</param>
        /// <param name="ideaId">idea id</param>
        /// <param name="emailType">email notification type</param>
        /// <param name="systemType">system notification type</param>
        /// <param name="actionUserId">action user id</param>
        /// <param name="url">target URL</param>
        /// <param name="processId">process id</param>
        /// <param name="elementId">element id</param>
        /// <param name="reason">text reason</param>
        /// <param name="rank">user rank</param>
        /// <param name="previousRank">user previous rank</param>
        /// <param name="session">SQL session</param>
        /// <param name="context">HTTP context</param>
        /// <param name="language">current language object</param>
        private static void RelatedContentUser(
            int currentUserId,
            int ideaId,
            Domain.Entities.Basic.EmailNotificationType?emailType,
            Domain.Entities.Basic.SystemNotificationType?systemType,
            int?actionUserId,
            string url,
            int?processId,
            int elementId,
            string reason,
            string rank,
            string previousRank,
            ISession session,
            HttpContextBase context,
            Domain.Entities.Language language)
        {
            IdeaRepository idea         = new IdeaRepository(session);
            List <int>     relatedUsers = idea.IdeaRelatedUsers(ideaId);

            relatedUsers.Remove(currentUserId);
            foreach (int id in relatedUsers)
            {
                Business.Utilities.Notification.NewNotification(id, emailType, systemType, actionUserId, url, processId, elementId, reason, rank, previousRank, session, context, language);
            }
        }
Example #3
0
        public JsonResult Borrar(int commentId)
        {
            bool result = false;

            int userId = ((CustomPrincipal)User).UserId;

            CommentRepository comment = new CommentRepository(SessionCustom);

            comment.Entity.CommentId = commentId;
            comment.LoadByKey();

            IdeaRepository idea = new IdeaRepository(SessionCustom);

            idea.Entity.IdeaId = comment.Entity.IdeaId;
            idea.LoadByKey();

            if (userId == comment.Entity.UserId /*|| userId == idea.Entity.UserId*/)
            {
                comment.Entity.Active = false;
                comment.Update();
                result = true;
            }

            return(this.Json(new { result = result }));
        }
Example #4
0
        public JsonResult GetIdeas(int mod, int page, string text, short?filter, bool?active)
        {
            StringBuilder strbl = new StringBuilder();

            IdeaRepository objidea   = new IdeaRepository(SessionCustom);
            PaginInfo      paginInfo = new PaginInfo()
            {
                PageIndex = page
            };

            objidea.Entity.Text   = text;
            objidea.Entity.Active = active;

            IEnumerable <Domain.Entities.Idea> ideas = objidea.GetAllPaging(filter, paginInfo);

            foreach (Domain.Entities.Idea idea in ideas)
            {
                strbl.AppendLine("<li id=\"li" + idea.IdeaId + "\" ondblclick=\"ctnback.editcontent(" + idea.IdeaId + ")\" onclick=\"if(ctnback.clicOk) { ctnback.contentselect(this, " + idea.IdeaId + "); } else { ctnback.clicOk = true; }\">");
                if (string.IsNullOrEmpty(idea.Image))
                {
                    strbl.AppendLine("<img id=\"" + idea.IdeaId + "\" class=\"handle\" src=\"" + Business.Utils.GetImageContent(idea.Image, idea.IdeaId.Value, 44, 44) + "\" width=\"44\" height=\"44\" />");
                }
                else
                {
                    strbl.AppendLine("<img id=\"" + idea.IdeaId + "\" class=\"handle\" src=\"/files/ideas/560x515-" + idea.Image + "\" width=\"44\" height=\"44\" />");
                }

                strbl.AppendLine("<div class=\"info-content\"><span title=\"Arrastre hacia una sección para cambiarla.\" class=\"sptitle cursor\">" + Business.Utils.TruncateWord(idea.Text, 85) + "</span><br />");
                strbl.AppendLine("<span class=\"spdate\">" + idea.Creationdate.Value.ToString("F") + "</span></div><div class=\"clear\"></div>");
                strbl.AppendLine("</li>");
            }

            return(this.Json(new { html = strbl.ToString(), count = ideas.Count(), total = paginInfo.TotalCount }, JsonRequestBehavior.AllowGet));
        }
Example #5
0
        /// <summary>
        /// gets the index of the idea module
        /// </summary>
        /// <returns>returns the result to action</returns>
        public ActionResult Index()
        {
            IdeaRepository  idea  = new IdeaRepository(SessionCustom);
            ModulRepository modul = new ModulRepository(SessionCustom);

            modul.Entity.ModulId    = 55;
            modul.Entity.LanguageId = CurrentLanguage.LanguageId;
            modul.Load();

            PaginInfo paginInfo = new PaginInfo()
            {
                PageIndex = 1
            };

            return(this.View(new Models.Idea()
            {
                UserPrincipal = CustomUser,
                Module = modul.Entity,
                CollIdea = idea.GetAllPaging(null, paginInfo),
                ColModul = CustomMemberShipProvider.GetModuls(CustomUser.UserId, SessionCustom, HttpContext),
                Total = paginInfo.TotalCount,
                Controller = modul.Entity.Controller,
                CurrentLanguage = CurrentLanguage
            }));
        }
Example #6
0
        public void Can_save_an_idea_to_a_database()
        {
            //Arrange
            IDbAdapter   database;
            const string ideaDescription = "test idea";

            try
            {
                database = SetupDatabase(false);
            }
            catch (FieldAccessException faex)
            {
                Console.WriteLine(faex.Message);
                database = SetupDatabase(false);
            }

            var repository = new IdeaRepository(database);

            //Act
            repository.Create(ideaDescription);

            //Assert
            var result = RetrieveIdeaCollectionFromDatabase(database);

            Assert.NotEmpty(result);
        }
Example #7
0
        /// <summary>
        /// obtains the idea detail
        /// </summary>
        /// <param name="mod">identifier of module</param>
        /// <param name="id">identifier of section</param>
        /// <returns>returns the result to action</returns>
        public ActionResult Detail(int mod, int id)
        {
            QuestionRepository   objquestion   = new QuestionRepository(SessionCustom);
            ContentManagement    objcontentman = new ContentManagement(SessionCustom, HttpContext);
            ContentRepository    objcontent    = new ContentRepository(SessionCustom);
            IdeaRepository       objidea       = new IdeaRepository(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;

            objidea.Entity.IdeaId        =
                objcomment.Entity.IdeaId = id;
            objidea.LoadByKey();

            objquestion.Entity.ContentId    =
                objcontent.Entity.ContentId = objidea.Entity.ContentId;
            objcontent.LoadByKey();
            objquestion.LoadByKey();

            if (objquestion.Entity != null && objquestion.Entity.Type.Equals(Domain.Entities.Question.TypeQuestion.Ubicacion))
            {
                ViewBag.Location = true;
            }
            else
            {
                ViewBag.Location = false;
            }

            int totalComments = 0;
            List <CommentsPaging> comments = objcomment.CommentsPaging(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(
                       "Detail",
                       new IdeaModel()
            {
                UserPrincipal = this.CustomUser,
                ColModul = CustomMemberShipProvider.GetModuls(this.CustomUser.UserId, this.SessionCustom, HttpContext),
                Module = this.Module,
                ListFiles = objfiles.GetAllReadOnly(),
                Idea = objidea.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
            }));
        }
Example #8
0
        private static IdeaController SetupIdeaController(SqlLiteDbIdeaAdapter sqlLiteDbIdeaAdapter, NotepadFrame notepadFrame,
                                                          ILoggingController loggingController)
        {
            var ideaRepository = new IdeaRepository(sqlLiteDbIdeaAdapter);
            var ideaService    = new IdeaService(ideaRepository);
            var ideaController = new IdeaController((TabControl)notepadFrame.splitControlArea.Panel1.Controls[0],
                                                    ideaService, loggingController);

            return(ideaController);
        }
Example #9
0
        public JsonResult UnBlockIdea(int id)
        {
            IdeaRepository objidea = new IdeaRepository(this.SessionCustom);

            objidea.Entity.IdeaId = id;
            objidea.LoadByKey();
            objidea.Entity.Active = true;
            objidea.Update();

            this.InsertAudit("Update", this.Module.Name + " -> Unblock Idea" + id + " " + objidea.Entity.Text);
            return(this.Json(new { result = true }));
        }
Example #10
0
        public void Can_retrieve_an_idea_by_id()
        {
            //Arrange
            var description = "test idea 11";
            var testItem    = new Idea(description);
            var repository  = new IdeaRepository(new SqlLiteDbIdeaAdapter(ConnectionString, DatabaseName));
            //Act
            var id = repository.Create(description);

            //Assert
            var result = repository.Get(id);

            Assert.Equal(testItem.Description, result.Description);
        }
Example #11
0
        public void Should_receive_record_id_after_record_insert()
        {
            //Arrange
            const string ideaDescription  = "test idea 10";
            var          sqlLiteDbAdapter = new SqlLiteDbIdeaAdapter(ConnectionString, DatabaseName);
            var          repository       = new IdeaRepository(sqlLiteDbAdapter);

            //Act
            int result = repository.Create(ideaDescription);


            //Assert
            Assert.IsType <int>(result);
        }
        public UnitOfWork(CrowdfundingSystemContext context)
        {
            this.context = context ?? throw new ArgumentNullException("Context was not supplied");

            IdeaRepository              = new IdeaRepository(context);
            UserRepository              = new UserRepository(context);
            MoneyTransferRepository     = new MoneyTransferRepository(context);
            CSOwnerRepository           = new CSOwnerRepository(context);
            InnerMoneyAccountRepository = new GenericRepository <InnerMoneyAccount>(context);
            BankAccountRepository       = new GenericRepository <BankAccount>(context);
            PhotoRepository             = new GenericRepository <Photo>(context);
            PositiveVoteRepository      = new GenericRepository <PositiveVote>(context);
            NegativeVoteRepository      = new GenericRepository <NegativeVote>(context);
        }
Example #13
0
        public ActionResult Comentario(int commentId, string view)
        {
            int?currentUserId = null;

            if (User.Identity.IsAuthenticated)
            {
                currentUserId = ((CustomPrincipal)User).UserId;
            }

            ViewBag.CurrentUserId = currentUserId;

            CommentRepository comment = new CommentRepository(SessionCustom);

            comment.Entity.CommentId = commentId;
            comment.LoadByKey();
            int total = 0;
            List <CommentsPaging> result = comment.CommentsPagingById(commentId, comment.Entity.IdeaId, comment.Entity.ContentId, out total);

            if (result.Count > 0)
            {
                result[0].CommentCount = total;
            }

            if (string.IsNullOrEmpty(view))
            {
                if (comment.Entity.IdeaId.HasValue)
                {
                    IdeaRepository idea = new IdeaRepository(SessionCustom);
                    idea.Entity.IdeaId = comment.Entity.IdeaId;
                    idea.LoadByKey();
                    ViewBag.Idea = idea.Entity;

                    view = "_ContentIdeaCommentsList";
                }
                else if (comment.Entity.CommentId.HasValue)
                {
                    view = "_BlogEntryCommentsList";
                }
            }

            if (string.IsNullOrEmpty(view))
            {
                return(null);
            }
            else
            {
                return(this.View(view, result));
            }
        }
Example #14
0
        public static ContentService CreateContentService()
        {
            IUnitOfWork             uow = new EFUnitOfWork();
            IArticleRepository      articleRepository      = new ArticleRepository(uow);
            ISiteNodeRepository     siteNodeRepository     = new SiteNodeRepository(uow);
            INewsRepository         newsRepository         = new NewsRepository(uow);
            ICompanyRepository      companyRepository      = new CompanyRepository(uow);
            IIdeaRepository         ideaRepository         = new IdeaRepository(uow);
            ICommentRepository      commentRepository      = new CommentRepository(uow);
            IVacancyRepository      vacancyRepository      = new VacancyRepository(uow);
            IAnnouncementRepository announcementRepository = new AnnouncementRepository(uow);

            return(new ContentService(articleRepository, siteNodeRepository, newsRepository, companyRepository, ideaRepository,
                                      commentRepository, vacancyRepository, announcementRepository, uow, HttpContext.Current));
        }
        public int send(int id)
        {
            var idea = IdeaRepository.find(id);

            if (idea.Status == "Accepted")
            {
                if (ConstructionController.getInstance().add(id))
                {
                    IdeaRepository.remove(id);
                    return(1);
                }

                return(0);
            }

            return(-1);
        }
Example #16
0
        public ActionResult ViewDetail(int id)
        {
            IdeaRepository    objidea    = new IdeaRepository(SessionCustom);
            UserRepository    objuser    = new UserRepository(SessionCustom);
            SectionRepository objSection = new SectionRepository(SessionCustom);

            objidea.Entity.IdeaId = id;
            objidea.Load();

            objuser.Entity.UserId = objidea.Entity.UserId;
            objuser.Load();

            return(this.View(new InfoIdea()
            {
                Idea = objidea.Entity,
                Autor = objuser.Entity.Names
            }));
        }
Example #17
0
        /// <summary>
        /// set a reward action for sharing the site content
        /// </summary>
        /// <param name="ideaId">idea id</param>
        /// <param name="network">social network name</param>
        /// <returns>A JSON object indicating if the process was successful or not</returns>
        public JsonResult Compartir(int ideaId, string network)
        {
            bool result = true;

            IdeaRepository idea = new IdeaRepository(SessionCustom);

            idea.Entity.IdeaId = ideaId;
            idea.LoadByKey();

            int?userId = null;

            if (User.Identity.IsAuthenticated)
            {
                userId = ((CustomPrincipal)User).UserId;
            }

            Business.Utilities.Notification.NewNotification(idea.Entity.UserId.Value, null, Domain.Entities.Basic.SystemNotificationType.RECEIVE_IDEA_SHARE, userId, string.Concat("/", idea.Entity.Friendlyurlid), idea.Entity.ContentId, idea.Entity.IdeaId.Value, null, null, null, this.SessionCustom, this.HttpContext, this.CurrentLanguage);

            return(this.Json(new { result = result }));
        }
Example #18
0
        public ActionResult Idea(int ideaId)
        {
            int total         = 0;
            int?currentUserId = null;

            if (User.Identity.IsAuthenticated)
            {
                currentUserId = ((CustomPrincipal)User).UserId;
            }

            IdeaRepository     idea     = new IdeaRepository(SessionCustom);
            CommentRepository  comment  = new CommentRepository(SessionCustom);
            QuestionRepository question = new QuestionRepository(SessionCustom);
            List <IdeasPaging> ideas    = new List <IdeasPaging>();

            IdeasPaging singleIdea = idea.IdeaPagingById(ideaId, currentUserId);

            ideas.Add(singleIdea);
            foreach (IdeasPaging item in ideas)
            {
                item.CollComment = comment.CommentsPaging(1, 1, out total, item.IdeaId.Value);
                if (item.CollComment.Count > 0)
                {
                    item.CollComment[0].CommentCount = total;
                }
            }

            if (ideas.Count > 0)
            {
                question.Entity.ContentId = singleIdea.ContentId;
                question.LoadByKey();
                if (question.Entity.EndDate.HasValue)
                {
                    ideas[0].QuestionType = question.Entity.Type;
                }
            }

            ViewBag.CurrentUserId = currentUserId;

            return(this.View("_CardIdeasList", ideas));
        }
Example #19
0
        public ActionResult Comentarios(int pageIndex, int pageSize, int ideaId, string view)
        {
            int?currentUserId = null;

            if (User.Identity.IsAuthenticated)
            {
                currentUserId = ((CustomPrincipal)User).UserId;
            }

            ViewBag.CurrentUserId = currentUserId;

            IdeaRepository idea = new IdeaRepository(SessionCustom);

            idea.Entity.IdeaId = ideaId;
            idea.LoadByKey();
            ViewBag.Idea = idea.Entity;
            if (idea.Entity.UserId == currentUserId)
            {
                ViewBag.IdeaOwner = true;
            }
            else
            {
                ViewBag.IdeaOwner = false;
            }

            if (string.IsNullOrEmpty(view))
            {
                view = "_ContentIdeaCommentsList";
            }

            int total = 0;
            CommentRepository     comment  = new CommentRepository(SessionCustom);
            List <CommentsPaging> comments = comment.CommentsPaging(pageIndex, pageSize, out total, ideaId);

            if (comments.Count > 0)
            {
                comments[0].CommentCount = total;
            }

            return(this.View(view, comments));
        }
Example #20
0
        public void Can_delete_an_idea_from_the_database()
        {
            //Arrange
            const string ideaDescription = "test idea";
            var          database        = SetupDatabase(true);
            var          repository      = new IdeaRepository(database);

            //Act
            repository.Create(ideaDescription);
            IList <Idea> resultCheckState = RetrieveIdeaCollectionFromDatabase(database);;

            Assert.NotEmpty(resultCheckState);

            repository.Delete(resultCheckState[0].Id);


            //Assert
            IEnumerable result = RetrieveIdeaCollectionFromDatabase(database);;

            Assert.Empty(result);
        }
Example #21
0
        public ActionResult Create(IdeaModel model, string deleteIdeaImage)
        {
            IdeaRepository objidea = new IdeaRepository(this.SessionCustom);

            try
            {
                this.SessionCustom.Begin();

                objidea.Entity = model.Idea;
                if (!string.IsNullOrEmpty(deleteIdeaImage))
                {
                    objidea.Entity.Image = null;
                }

                objidea.Update();
                this.InsertAudit("Update", this.Module.Name + " -> " + model.Idea.IdeaId);

                this.SessionCustom.Commit();
            }
            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", "Idea"));
            }
            else
            {
                return(this.RedirectToAction("Detail", "Idea", new { mod = Module.ModulId, id = objidea.Entity.IdeaId }));
            }
        }
Example #22
0
        /// <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?LanguageId)
        {
            int count = 0;

            this.RawDate = string.Empty;

            this.Start = null;
            this.End   = null;

            string rawUrl    = context.Request.RawUrl.ToLower();
            string rangeDate = rawUrl.Split('/').LastOrDefault();

            this.View = string.Empty;

            if (rawUrl.IndexOf("/ranking") >= 0)
            {
                this.View = "ranking";
            }

            if (rawUrl.IndexOf("/categorias") >= 0)
            {
                this.View = "categorias";
            }

            if (rawUrl.IndexOf("/profesiones") >= 0)
            {
                this.View = "profesiones";
            }

            if (rawUrl.IndexOf("/tendencias") >= 0)
            {
                this.View = "tendencias";
            }

            if (rangeDate.Length == 21)
            {
                int[] dateParams = rangeDate.Split('-').Select(s => Convert.ToInt32(s)).ToArray();
                if (dateParams.Count() == 6)
                {
                    this.Start = new DateTime(dateParams[0], dateParams[1], dateParams[2]);
                    this.End   = new DateTime(dateParams[3], dateParams[4], dateParams[5]);
                    this.End   = this.End.Value.AddDays(1).AddSeconds(-1);

                    this.RawDate = string.Concat(this.Start.Value.ToString("yyyy-MM-dd"), " - ", this.End.Value.ToString("yyyy-MM-dd"));
                }
            }

            if (string.IsNullOrEmpty(this.View))
            {
                IdeaRepository idea = new IdeaRepository(session);
                UserRepository user = new UserRepository(session);

                this.ActiveUsers = user.CountActiveUserByDate(this.Start, this.End, 0, 6);

                DataTable profession = user.CountProfessionByDate(this.Start, this.End, 0, 6);
                this.Professions = new Dictionary <string, string>();
                if (profession.Rows.Count > 0)
                {
                    foreach (DataRow row in profession.Rows)
                    {
                        this.Professions.Add(row["Profession"].ToString(), row["Count"].ToString());
                    }
                }

                profession.Dispose();

                DataTable category = user.CountCategoryPulsesByDate(this.Start, this.End, 0, 6);
                this.Categories = new Dictionary <string, string>();
                if (category.Rows.Count > 0)
                {
                    foreach (DataRow row in category.Rows)
                    {
                        this.Categories.Add(row["Category"].ToString(), row["Count"].ToString());
                    }
                }

                category.Dispose();
                DataTable hashtag = user.CountHashTagByDate(this.Start, this.End, 0, 6);
                this.Hashtags = new Dictionary <string, string>();
                if (hashtag.Rows.Count > 0)
                {
                    foreach (DataRow row in hashtag.Rows)
                    {
                        this.Hashtags.Add(row["HashTag"].ToString(), row["Count"].ToString());
                    }
                }

                hashtag.Dispose();

                this.Ideas      = idea.TopIdeasHome(8);
                this.TotalIdeas = idea.CountIdeaByDate(this.Start, this.End);
                DataTable userCount = user.CountUserByDate(this.Start, this.End);
                if (userCount.Rows.Count > 0)
                {
                    if (int.TryParse(userCount.Rows[0]["Total"].ToString(), out count))
                    {
                        this.TotalUsers = count;
                    }

                    if (int.TryParse(userCount.Rows[0]["Male"].ToString(), out count))
                    {
                        this.Male = count;
                    }

                    if (int.TryParse(userCount.Rows[0]["Female"].ToString(), out count))
                    {
                        this.Female = count;
                    }

                    if (int.TryParse(userCount.Rows[0]["Unknown"].ToString(), out count))
                    {
                        this.Unknown = count;
                    }
                }

                userCount.Dispose();

                DataTable ageCount = user.CountAgeByDate(this.Start, this.End);
                this.Ages = new Dictionary <string, string>();
                if (ageCount.Rows.Count > 0)
                {
                    foreach (DataColumn column in ageCount.Columns)
                    {
                        this.Ages.Add(column.ColumnName, ageCount.Rows[0][column.ColumnName].ToString());
                    }
                }

                ageCount.Dispose();

                DataTable interest = user.CountInterestByDate(this.Start, this.End);
                this.Interests = new Dictionary <string, string>();
                if (interest.Rows.Count > 0)
                {
                    foreach (DataRow row in interest.Rows)
                    {
                        this.Interests.Add(row["Name"].ToString(), row["Interest"].ToString());
                    }
                }

                interest.Dispose();
            }
        }
 public RecentIdeasController()
 {
     _ideaRepository = new IdeaRepository();
 }
Example #24
0
        /// <summary>
        /// a set of administrator actions can be executed according to the parameters
        /// </summary>
        /// <param name="id">element id</param>
        /// <param name="type">element type</param>
        /// <param name="action">action type</param>
        /// <param name="reason">reason text</param>
        /// <returns>A JSON object indicating if the process was successful or not</returns>
        public JsonResult AdminAction(int id, string type, string action, string reason)
        {
            bool   result = false;
            string view   = string.Empty;

            if (((CustomPrincipal)User).IsFrontEndAdmin)
            {
                if (type == "idea")
                {
                    IdeaRepository idea = new IdeaRepository(SessionCustom);
                    idea.Entity.IdeaId = id;
                    idea.LoadByKey();
                    switch (action)
                    {
                    case "recommend":
                        idea.Entity.Recommended = true;
                        break;

                    case "disable":
                        idea.Entity.Active = false;
                        string url = string.Concat("http://", Request.Url.Host + Request.ApplicationPath).TrimEnd('/');
                        Business.Utilities.Notification.NewNotification(idea.Entity.UserId.Value, Domain.Entities.Basic.EmailNotificationType.IDEA_BLOCKED, null, null, url, idea.Entity.ContentId, idea.Entity.IdeaId.Value, reason, null, null, this.SessionCustom, this.HttpContext, this.CurrentLanguage);
                        break;
                    }

                    idea.Update();
                    result = true;
                }

                if (type == "comment")
                {
                    CommentRepository comment = new CommentRepository(SessionCustom);
                    comment.Entity.CommentId = id;
                    switch (action)
                    {
                    case "disable":
                        comment.Entity.Active = false;
                        break;
                    }

                    comment.Update();
                    result = true;
                }

                if (type == "frontend")
                {
                    switch (id)
                    {
                    case (int)Domain.Entities.Basic.ForntEndEditableType.LOGO:
                        view = "logo";
                        break;

                    case (int)Domain.Entities.Basic.ForntEndEditableType.MENU_HOME:
                        view = "menuhome";
                        break;

                    case (int)Domain.Entities.Basic.ForntEndEditableType.MENU_ARTICLES:
                        view = "menuarticles";
                        break;

                    case (int)Domain.Entities.Basic.ForntEndEditableType.MENU_FAQ:
                        view = "menufaq";
                        break;

                    case (int)Domain.Entities.Basic.ForntEndEditableType.HEADER_IMAGE:
                    case (int)Domain.Entities.Basic.ForntEndEditableType.HEADER_SMALL:
                    case (int)Domain.Entities.Basic.ForntEndEditableType.HEADER_BIG:
                        view = "header";
                        break;

                    case (int)Domain.Entities.Basic.ForntEndEditableType.BACKGROUND_COLOR:
                        view = "general";
                        break;

                    case (int)Domain.Entities.Basic.ForntEndEditableType.PULSES_DESCRIPTION:
                    case (int)Domain.Entities.Basic.ForntEndEditableType.PULSES_TOOLTIP:
                        view = "pulses";
                        break;

                    case (int)Domain.Entities.Basic.ForntEndEditableType.USERS_DESCRIPTION:
                        view = "users";
                        break;

                    case (int)Domain.Entities.Basic.ForntEndEditableType.IDEAS_DESCRIPTION:
                        view = "ideas";
                        break;

                    case (int)Domain.Entities.Basic.ForntEndEditableType.STATISTICS_USER_TOP:
                        view = "Statistics";
                        break;

                    case (int)Domain.Entities.Basic.ForntEndEditableType.COMMUNITY_TEXT_1:
                        view = "Community";
                        break;

                    case (int)Domain.Entities.Basic.ForntEndEditableType.CHALLENGES_DESCRIPTION:
                        view = "challenge";
                        break;

                    case (int)Domain.Entities.Basic.ForntEndEditableType.QUESTIONS_DESCRIPTION:
                        view = "question";
                        break;

                    case (int)Domain.Entities.Basic.ForntEndEditableType.ARTICLES_SINGULAR:
                    case (int)Domain.Entities.Basic.ForntEndEditableType.ARTICLES_PLURAL:
                        view = "article";
                        break;

                    case (int)Domain.Entities.Basic.ForntEndEditableType.FOOTER_OWNER:
                        view = "footerowner";
                        break;

                    case (int)Domain.Entities.Basic.ForntEndEditableType.FOOTER_SPONSOR:
                        view = "footersponsor";
                        break;

                    case (int)Domain.Entities.Basic.ForntEndEditableType.FOOTER_CONTACT_US:
                        view = "footer";
                        break;

                    case (int)Domain.Entities.Basic.ForntEndEditableType.PULSE_VS:
                        view = "pulsevs";
                        break;

                    case (int)Domain.Entities.Basic.ForntEndEditableType.PULSE_TOP:
                        view = "pulsetop";
                        break;
                    }

                    result = true;
                }
            }

            return(this.Json(new { result = result, view = view }));
        }
Example #25
0
        /// <summary>
        /// gets the home of content according to identifier
        /// </summary>
        /// <param name="id">identifier of content</param>
        /// <returns>returns the result to action</returns>
        public ActionResult Index(int id)
        {
            SetLabel();
            bool versus = false;
            FrontEndManagement   objman     = new FrontEndManagement(SessionCustom, HttpContext, FrontEndManagement.Type.Content, CurrentLanguage);
            BannerRepository     banner     = new BannerRepository(SessionCustom);
            IdeaRepository       idea       = new IdeaRepository(SessionCustom);
            UserAnswerRepository userAnswer = new UserAnswerRepository(SessionCustom);
            bool voted = false;

            idea.Entity.ContentId = id;

            int?currentUserId = null;

            if (User.Identity.IsAuthenticated)
            {
                currentUserId = ((CustomPrincipal)User).UserId;
                objman.BindInfo(id, currentUserId.Value);
                versus = Business.Utils.CheckVersus(((CustomPrincipal)User).UserId, id, this.SessionCustom);
                voted  = userAnswer.CheckUserVoted(((CustomPrincipal)User).UserId, id, null);
            }
            else
            {
                objman.BindInfo(id, null);
                versus = true;
            }

            ViewBag.CurrentUserId = currentUserId;

            if (!objman.Content.Active.Value)
            {
                return(this.Redirect("~/" + objman.Section.Friendlyname));
            }

            if (objman.Outcome == FrontEndManagement.Result.Ok)
            {
                ViewBag.Ideas = idea.GetAll();
                return(this.View(
                           objman.Template,
                           new Models.FEContenido()
                {
                    UserPrincipal = CustomUser,
                    PageTitle = string.Format("{0} | {1}", ConfigurationManager.AppSettings["TitleHome"], objman.Content.Name),
                    Content = objman.Content,
                    Section = objman.Section,
                    Layout = objman.Layout + ".cshtml",
                    Entity = objman.Detail,
                    MetaTags = objman.Metatags,
                    Banners = banner.GetBannersBySection(objman.Section.SectionId.Value, CurrentLanguage.LanguageId.Value),
                    DeepFollower = objman.DeepFollower,
                    CurrentLanguage = CurrentLanguage,
                    IdeasCountAll = idea.IdeasCountAll(),
                    Versus = versus,
                    Voted = voted
                }));
            }
            else if (objman.Outcome == FrontEndManagement.Result.NotFound)
            {
                return(this.View(
                           "Mensaje",
                           new FEMessage()
                {
                    PageTitle = "Recurso no encontrado",
                    UserPrincipal = CustomUser,
                    Banners = banner.GetBannersBySection(0, CurrentLanguage.LanguageId.Value),
                    Title = "Recurso no encontrado",
                    Description = "Recurso no encontrado",
                    Message = Resources.Extend.Messages.RESOURCE_NOT_FOUND,
                    CurrentLanguage = CurrentLanguage
                }));
            }
            else
            {
                return(this.View(
                           "Mensaje",
                           new FEMessage()
                {
                    PageTitle = "Sistema no disponible",
                    UserPrincipal = CustomUser,
                    Banners = banner.GetBannersBySection(0, CurrentLanguage.LanguageId.Value),
                    Title = "Sistema no disponible",
                    Description = "Sistema no disponible",
                    Message = Resources.Extend.Messages.SYSTEM_ERROR,
                    CurrentLanguage = CurrentLanguage
                }));
            }
        }
Example #26
0
 public IdeasController()
 {
     _ideaRepository = new IdeaRepository(SessionUser);
     _ideaRepository.OnChange += SyncManager.OnChange;
 }
 public List <Idea> getAll()
 {
     return(IdeaRepository.getAll());
 }
        public bool insert(string title, string information)
        {
            Idea idea = IdeaFactory.create(title, information);

            return(IdeaRepository.insert(idea));
        }
Example #29
0
        public ActionResult Ideas(int pageIndex, int pageSize, int contentId, int filter, string view, int[] ideasId)
        {
            int total         = 0;
            int?currentUserId = null;

            if (User.Identity.IsAuthenticated)
            {
                currentUserId = ((CustomPrincipal)User).UserId;
            }

            IdeaRepository     idea     = new IdeaRepository(SessionCustom);
            CommentRepository  comment  = new CommentRepository(SessionCustom);
            QuestionRepository question = new QuestionRepository(SessionCustom);
            List <IdeasPaging> ideas    = new List <IdeasPaging>();

            switch (filter)
            {
            case 1:
                ideas = idea.IdeasPagingRandom(pageSize, out total, contentId, currentUserId, ideasId);
                break;

            case 2:
                ideas = idea.IdeasPaging(pageIndex, pageSize, out total, contentId, currentUserId);
                break;

            case 3:
                ideas = idea.IdeasPagingTop(pageIndex, pageSize, out total, contentId, currentUserId);
                break;

            case 4:
                ideas = idea.IdeasPagingRecommended(pageIndex, pageSize, out total, contentId, currentUserId);
                break;
            }

            foreach (IdeasPaging item in ideas)
            {
                item.CollComment = comment.CommentsPaging(1, 1, out total, item.IdeaId.Value);
                if (item.CollComment.Count > 0)
                {
                    item.CollComment[0].CommentCount = total;
                }
            }

            if (string.IsNullOrEmpty(view))
            {
                view = "_CardIdeasList";
            }

            if (ideas.Count > 0)
            {
                question.Entity.ContentId = contentId;
                question.LoadByKey();
                if (question.Entity.EndDate.HasValue)
                {
                    ideas[0].QuestionType = question.Entity.Type;
                }
            }

            ViewBag.CurrentUserId = currentUserId;

            return(this.View(view, ideas));
        }
Example #30
0
 public TransactionsController()
 {
     _transactionRepository = new TransactionRepository();
     _ideaRepository        = new IdeaRepository();
 }
 public void update(int id, string note, string status)
 {
     IdeaRepository.update(id, note, status);
 }