Example #1
0
        public void EditPost()
        {
            var UoW = new Mock <UnitOfWork>();

            UoW.Object.DeleteDB();

            var PostLogic = new PostLogic(UoW.Object);
            var UserLogic = new UserLogic(UoW.Object);

            UserLogic.AddUser(new UserDTO("Liza", UserType.Manager, "Bril", "Login", "Password"));
            UserLogic.Login("Login", "Password");
            PostLogic.Add(new PostDTO("Title", "Content", "Tag", "CategoryName"));

            var Post = PostLogic.GetAll().ToList()[0];

            Assert.AreEqual(PostLogic.GetAll().Count(), 1);
            Assert.AreEqual(PostLogic.GetAll().ToList()[0].Title, "Title");
            Assert.AreEqual(PostLogic.GetAll().ToList()[0].Content, "Content");
            Assert.AreEqual(PostLogic.GetAll().ToList()[0].Tags, "Tag");
            Assert.AreEqual(PostLogic.GetAll().ToList()[0].CategoryName, "CategoryName");

            Post.Title        = "Programming";
            Post.CategoryName = "C#";

            PostLogic.EditPost(Post.Id, Post);

            Post = PostLogic.GetAll().ToList()[0];

            Assert.AreEqual(PostLogic.GetAll().Count(), 1);
            Assert.AreEqual(PostLogic.GetAll().ToList()[0].Title, "Programming");
            Assert.AreEqual(PostLogic.GetAll().ToList()[0].Content, "Content");
            Assert.AreEqual(PostLogic.GetAll().ToList()[0].Tags, "Tag");
            Assert.AreEqual(PostLogic.GetAll().ToList()[0].CategoryName, "C#");
        }
Example #2
0
 public TimeLine(User user, Event ev)
 {
     InitializeComponent();
     _user  = user;
     _event = ev;
     _logic = new PostLogic();
 }
Example #3
0
 public SearchByTag(User user, Event ev)
 {
     InitializeComponent();
     _user  = user;
     _event = ev;
     _logic = new PostLogic();
 }
Example #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //Obtencion de parametro y objeto desde base de datos
            int  postId = Convert.ToInt32(this.URLParams.DecodeParam(Page.Request.QueryString["postId"]));
            Post post   = new PostLogic().GetPostById(new Post(postId));

            this.encryptedKey.Value = this.URLParams.EncodeParam(postId.ToString());

            //Logica si el usuario es propietario.
            if (post.User.UserId.Equals(this.WebProfile.User.UserId))
            {
                this.btnFavorite.Visible = false;
                this.btnDelete.Visible   = true;
                this.btnEdit.Visible     = true;
                this.btnEdit.HRef        = "~/pagesPost/EditPost.aspx?postId=" + this.URLParams.EncodeParam(postId.ToString());
            }
            else
            {
                this.btnFavorite.Visible = true;
                this.btnDelete.Visible   = false;
                this.btnEdit.Visible     = false;
            }

            //Seteo de valores en la pantalla
            this.lblTitle.InnerHtml    = post.Title;
            this.lblTopic.InnerHtml    = post.Topic.Name;
            this.lblSubTopic.InnerHtml = post.SubTopic.Name;
            this.lblLevel.InnerHtml    = post.DifficultyLevel.Description;
            operationResult.InnerHtml  = post.ContentPost;
        }
 public AccountController(IUserRepository iUserRepo, IAuraRepository iAuraRepo, ICategoryRepository iCategoryRepo, IPostrepository iPostRepo)
 {
     _accountLogic  = new UserLogic(iUserRepo);
     _auraLogic     = new AuraLogic(iAuraRepo);
     _categoryLogic = new CategoryLogic(iCategoryRepo);
     _postLogic     = new PostLogic(iPostRepo);
 }
Example #6
0
 public FormEmployee(EmployeeLogic employeeLogic, BranchLogic branchLogic, PostLogic postLogic)
 {
     InitializeComponent();
     this.employeeLogic = employeeLogic;
     _branchLogic       = branchLogic;
     _postLogic         = postLogic;
 }
Example #7
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                if (ValidateImputs())
                {
                    Post post = new Post();
                    post.Title           = this.GetParamString(this.txtTitle.UniqueID);
                    post.Tags            = this.GetParamString(this.txtTags.UniqueID);
                    post.ContentPost     = this.GetParamString(this.txtContent.UniqueID);
                    post.DifficultyLevel = new DifficultyLevel(this.GetParamInt(this.cboLevel.UniqueID));
                    post.Topic           = new Topic(this.GetParamInt(this.cboTopic.UniqueID));
                    post.SubTopic        = new SubTopic(this.GetParamInt(this.cboSubTopics.UniqueID));
                    post.User            = this.WebProfile.User;

                    PostLogic postLogic = new PostLogic();
                    post = postLogic.InsertPost(post);
                    if (post.OperationResult)
                    {
                        //Si el post se guardo, seteo una variable de sesion para y redirigo a la pagina de edición del post.
                        //Con la variable de sesion, muestro el mensaje de OK en la pantalla de edicion
                        Session[SessionKeys.PostSaveSuccess] = true;
                        Response.Redirect("~/pagesPost/EditPost.aspx?postId=" + post.PostId, false);
                    }
                    else
                    {
                        this.operationResult.InnerHtml = this.MessageDanger(post.OperationMessage);
                    }
                }
                else
                {
                    this.operationResult.InnerHtml = this.MessageDanger("Algunos de los datos ingresados no son válidos.");
                }
            }
        }
Example #8
0
        public PostController(IOptions <GlobalSetting> optionsAccessor, IPaginatedMetaService paginatedMetaService)
        {
            _optionsAccessor      = optionsAccessor;
            _paginatedMetaService = paginatedMetaService;
            _itemsPerPage         = _optionsAccessor.Value.MAX_VIEW_WEB_COUNT_POSTS;

            _postLogic = new PostLogic(_itemsPerPage);
        }
Example #9
0
 public ReportSection(User admin, Event ev)
 {
     InitializeComponent();
     _admin             = admin;
     _event             = ev;
     _logicPost         = new PostLogic();
     _getAllPostByEvent = _logicPost.GetAllByEvent(_event);
     lblWelkom.Text     = $"Welkom bij de rapporten overzicht,  {_admin.Name} {_admin.Surname}";
 }
Example #10
0
 public void Initialize()
 {
     _mockPostRepo     = new MockPostRepository();
     _postLogic        = new PostLogic(_mockPostRepo);
     _mockAuraRepo     = new MockAuraRepository();
     _auraLogic        = new AuraLogic(_mockAuraRepo);
     _mockUserRepo     = new MockUserRepository();
     _userLogic        = new UserLogic(_mockUserRepo);
     _mockCategoryRepo = new MockCategoryRepository();
     _categoryLogic    = new CategoryLogic(_mockCategoryRepo);
 }
Example #11
0
        /// <summary>
        /// Constructor used for the post form for users
        /// </summary>
        /// <param name="user">The user who is placing this post</param>
        /// <param name="ev">The event this post belongs to</param>
        public MakePost(User user, Event ev)
        {
            _user = user;
            InitializeComponent();
            _event     = ev;
            _logicPost = new PostLogic(new PostOracleContext());

            _uploadedMedia = new UcUpload(_user, _event);
            tbpLoadUcUpload.Controls.Add(_uploadedMedia);
            LoadMediaList();
        }
Example #12
0
        public PostFeedExtended(Post post, Event ev, User user)
        {
            InitializeComponent();
            _logicPost     = new PostLogic();
            _reportContext = new ReportOracleContext();

            _post  = post;
            _event = ev;

            _activeUser = user;
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            //ToDo: Chequear que venga el parametro QueryString["subTopicId"]

            int           subTopicId = Convert.ToInt32(this.URLParams.DecodeParam(Request.QueryString["subTopicId"]));
            StringBuilder sb         = new StringBuilder();
            List <Post>   postList   = new PostLogic().GetPostBySubTopicId(new SubTopic()
            {
                SubTopicId = subTopicId
            });

            this.content.InnerHtml = new UIBuilder().GetPostBySubTopicId(postList);
        }
Example #14
0
 public async Task OnSaveAsync()
 {
     try
     {
         if (!await PostLogic.CreatePostAsync(Post))
         {
             throw new UserException("Post not Created");
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
Example #15
0
 protected override async Task OnInitializedAsync()
 {
     try
     {
         Post = await PostLogic.GetPostAsync(Id);
     }
     catch (FormatException e)
     {
         Logger.LogWarning(e, e.Message);
         NavigationManager.NavigateTo("/Error");
     }
     catch (Exception e)
     {
         Logger.LogError(e, e.Message);
         NavigationManager.NavigateTo("/Error");
     }
     await base.OnInitializedAsync();
 }
Example #16
0
        public void AddCommentToPost()
        {
            var UoW = new Mock <UnitOfWork>();

            UoW.Object.DeleteDB();

            var PostLogic = new PostLogic(UoW.Object);
            var UserLogic = new UserLogic(UoW.Object);

            UserLogic.AddUser(new UserDTO("Liza", UserType.Manager, "Bril", "Login", "Password"));
            UserLogic.Login("Login", "Password");
            PostLogic.Add(new PostDTO("Title", "Content", "Tag", "CategoryName"));
            PostLogic.AddComment(PostLogic.GetAll().ToList()[0].Id, new CommentsDTO("Great Post", 0, true));

            Assert.AreEqual(UoW.Object.Comments.GetAll().Count(), 1);
            Assert.AreEqual(PostLogic.GetAll().ToList()[0].Comments[0].Comment_Content, "Great Post");
            Assert.IsTrue(PostLogic.GetAll().ToList()[0].Comments[0].Publish == true);
            Assert.IsTrue(PostLogic.GetAll().ToList()[0].Comments[0].Post.Id == PostLogic.GetAll().ToList()[0].Id);
        }
Example #17
0
        public void SearchByTag()
        {
            var UoW = new Mock <UnitOfWork>();

            UoW.Object.DeleteDB();

            var PostLogic = new PostLogic(UoW.Object);
            var UserLogic = new UserLogic(UoW.Object);

            UserLogic.AddUser(new UserDTO("Liza", UserType.Manager, "Bril", "Login", "Password"));
            UserLogic.Login("Login", "Password");
            PostLogic.Add(new PostDTO("Title", "Content", "Tag", "CategoryName"));
            PostLogic.Add(new PostDTO("Title1", "Content1", "Tag1", "CategoryName1"));
            PostLogic.Add(new PostDTO("Title2", "Content2", "Tag2", "CategoryName2"));
            PostLogic.Add(new PostDTO("Title3", "Content3", "Tag3", "CategoryName3"));
            PostLogic.Add(new PostDTO("Title4", "Content4", "Tag4", "CategoryName4"));

            Assert.IsTrue(PostLogic.GetAll().Count() == 5);

            Assert.AreEqual(PostLogic.SearchByTag("Tag1").ToList()[0].Tags, "Tag1");
            Assert.AreEqual(PostLogic.SearchByTag("Tag4").ToList()[0].Tags, "Tag4");
        }
Example #18
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                try
                {
                    Post post = new Post();
                    post.PostId = Convert.ToInt32(this.URLParams.DecodeParam(this.encryptedKey.Value));

                    post.Title           = this.GetParamString(this.txtTitle.UniqueID);
                    post.Tags            = this.GetParamString(this.txtTags.UniqueID);
                    post.ContentPost     = this.GetParamString(this.txtContent.UniqueID);
                    post.DifficultyLevel = new DifficultyLevel(this.GetParamInt(this.cboLevel.UniqueID));
                    post.Topic           = new Topic(this.GetParamInt(this.cboTopic.UniqueID));
                    post.SubTopic        = new SubTopic(this.GetParamInt(this.cboSubTopics.UniqueID));
                    post.User            = this.WebProfile.User;

                    PostLogic postLogic  = new PostLogic();
                    Post      resultPost = postLogic.UpdatePost(post, this.WebProfile.User);
                    if (resultPost.OperationResult)
                    {
                        //Si el post se edito, seteo una variable de sesion para y redirigo a la pagina de edición del post.
                        //Con la variable de sesion, muestro el mensaje de OK en la pantalla de edicion
                        Session[SessionKeys.PostEditSuccess] = true;
                        Response.Redirect("~/pagesPost/EditPost.aspx?postId=" + this.URLParams.EncodeParam(post.PostId.ToString()), false);
                    }
                    else
                    {
                        this.operationResult.InnerHtml = this.MessageDanger(resultPost.OperationMessage);
                    }
                }
                catch (Exception ex)
                {
                    this.LogError(ex);
                    this.operationResult.InnerHtml = this.MessageDanger("Algunos de los datos ingresados no son válidos.");
                }
            }
        }
Example #19
0
        //============search==============
        public ActionResult AdminSearch(string keyword)
        {
            //authorize admin
            if (acl.AuthorizeAdmin(User.Identity.GetUserId()) == false)
            {
                return(HttpNotFound());
            }

            ViewData["keyword"] = keyword;
            AdminViewModel result = new AdminViewModel();

            //subcategory
            var temp = typel.SearchSubcategory(keyword);

            result.Subcategories = new List <Subcategory>(temp);

            //category
            var temp1 = typel.SearchCategory(keyword);

            result.Categories = new List <Category>(temp1);

            //areas
            var temp2 = locl.SearchArea(keyword);

            result.Areas = new List <Area>(temp2);

            //locales
            var temp3 = locl.SearchLocale(keyword);

            result.Locales = new List <Locale>(temp3);

            var temp4 = PostLogic.SearchPost(keyword);

            result.Posts = new List <Post>(temp4);

            return(View(result));
        }
Example #20
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session[SessionKeys.PostSaveSuccess] != null)
            {
                this.operationResult.InnerHtml       = this.MessageSuccess("Tu post se guardo correctamente.");
                Session[SessionKeys.PostSaveSuccess] = null;
            }
            else if (Session[SessionKeys.PostEditSuccess] != null)
            {
                this.operationResult.InnerHtml       = this.MessageSuccess("Tu post se editó correctamente.");
                Session[SessionKeys.PostEditSuccess] = null;
            }

            //Obtencion de parametro y almacenado en hidden para poder usarlo luego.
            int postId = Convert.ToInt32(this.URLParams.DecodeParam(Page.Request.QueryString["postId"]));

            this.encryptedKey.Value = this.URLParams.EncodeParam(postId.ToString());

            //Seteamos los valores en la pantalla
            Post post = new PostLogic().GetPostById(new Post(postId));

            this.txtTitle.Value         = post.Title;
            this.txtContent.Text        = post.ContentPost;
            this.txtTags.Value          = post.Tags;
            this.cboTopic.SelectedValue = post.Topic.TopicId.ToString();

            List <SubTopic> subTopicList = new TopicsLogic().GetSubTopicsByTopicId(post.Topic);

            foreach (SubTopic subTopicObject in subTopicList)
            {
                ListItem lItem = new ListItem(subTopicObject.Name, subTopicObject.SubTopicId.ToString());
                this.cboSubTopics.Items.Add(lItem);
            }
            this.cboSubTopics.SelectedValue = post.SubTopic.SubTopicId.ToString();

            this.cboLevel.SelectedValue = post.DifficultyLevel.DifficultyLevelId.ToString();
        }
Example #21
0
        public void FindByCategory()
        {
            var UoW = new Mock <UnitOfWork>();

            UoW.Object.DeleteDB();

            var PostLogic = new PostLogic(UoW.Object);
            var UserLogic = new UserLogic(UoW.Object);

            UserLogic.AddUser(new UserDTO("Liza", UserType.Manager, "Bril", "Login", "Password"));
            UserLogic.Login("Login", "Password");
            PostLogic.Add(new PostDTO("Title", "Content", "Tag", "C#"));
            PostLogic.Add(new PostDTO("Title1", "Content1", "Tag1", "C++"));
            PostLogic.Add(new PostDTO("Title2", "Content2", "Tag2", "Java"));
            PostLogic.Add(new PostDTO("Title3", "Content3", "Tag3", "Python"));
            PostLogic.Add(new PostDTO("Title4", "Content4", "Tag4", "JS"));

            Assert.IsTrue(PostLogic.GetAll().Count() == 5);

            Assert.AreEqual(PostLogic.FindByCategory("C#").ToList()[0].CategoryName, "C#");
            Assert.AreEqual(PostLogic.FindByCategory("C++").ToList()[0].CategoryName, "C++");
            Assert.AreEqual(PostLogic.FindByCategory("JS").ToList()[0].CategoryName, "JS");
            Assert.AreEqual(PostLogic.FindByCategory("Java").ToList()[0].CategoryName, "Java");
        }
Example #22
0
        public void DeletePost()
        {
            var UoW = new Mock <UnitOfWork>();

            UoW.Object.DeleteDB();

            var PostLogic = new PostLogic(UoW.Object);
            var UserLogic = new UserLogic(UoW.Object);

            UserLogic.AddUser(new UserDTO("Liza", UserType.Manager, "Bril", "Login", "Password"));
            UserLogic.Login("Login", "Password");
            PostLogic.Add(new PostDTO("Title", "Content", "Tag", "CategoryName"));

            Assert.AreEqual(PostLogic.GetAll().Count(), 1);
            Assert.AreEqual(PostLogic.GetAll().ToList()[0].Title, "Title");
            Assert.AreEqual(PostLogic.GetAll().ToList()[0].Content, "Content");
            Assert.AreEqual(PostLogic.GetAll().ToList()[0].Tags, "Tag");
            Assert.AreEqual(PostLogic.GetAll().ToList()[0].CategoryName, "CategoryName");

            PostLogic.DeletePost(1);

            Assert.IsTrue(PostLogic.GetAll().Count() == 0);
            Assert.IsTrue(UoW.Object.Post.GetAll().Count == 0);
        }
Example #23
0
        public TimelineController(IConfiguration config)
        {
            _postLogic = new PostLogic(config);

            _friendLogic = new FriendLogic(config);
        }
Example #24
0
 public HomeController(IPostContext postContext)
 {
     _IPostContext = postContext;
     postLogic     = new PostLogic(_IPostContext);
 }
 public CategoryController(ICategoryRepository iCategoryRepo, IPostrepository iPostRepo)
 {
     _categoryLogic = new CategoryLogic(iCategoryRepo);
     _postLogic     = new PostLogic(iPostRepo);
 }
Example #26
0
 public SubmitController(ICategoryRepository iCategoryRepo, IPostrepository iPostRepo, IAuraRepository iAuraRepo)
 {
     _categoryLogic = new CategoryLogic(iCategoryRepo);
     _postLogic     = new PostLogic(iPostRepo);
     _auraLogic     = new AuraLogic(iAuraRepo);
 }
 public FormPost(PostLogic post)
 {
     logic = post;
     InitializeComponent();
 }
 public FormStaff(PostLogic post, StaffLogic staff)
 {
     logicP = post;
     logic  = staff;
     InitializeComponent();
 }
Example #29
0
        /// <summary>
        /// Get input from users for all post entries
        /// </summary>
        static void Parse()
        {
            string error = string.Empty;
            string Title;
            string uri;
            string Author;
            int    Points;
            int    Comments;
            int    Rank;

            try
            {
                PostLogic postLogic = new PostLogic();

                Console.WriteLine("Number of posts {0}", Program.Posts);

                for (int i = 1; i <= Program.Posts; i++)
                {
                    while (true)
                    {
                        Console.WriteLine("Please enter the title for Post No {0}", i);
                        Title = Console.ReadLine();
                        if (!ValidatePostInput.ValidateTitle(Title, out error))
                        {
                            Console.WriteLine(error);
                        }
                        else
                        {
                            break;
                        }
                    }

                    while (true)
                    {
                        Console.WriteLine("Please enter the uri for Post No {0}", i);
                        uri = Console.ReadLine();
                        if (!ValidatePostInput.ValidateUri(uri, out error))
                        {
                            Console.WriteLine(error);
                        }
                        else
                        {
                            break;
                        }
                    }

                    while (true)
                    {
                        Console.WriteLine("Please enter the Author for Post No {0}", i);
                        Author = Console.ReadLine();
                        if (!ValidatePostInput.ValidateAuthor(Author, out error))
                        {
                            Console.WriteLine(error);
                        }
                        else
                        {
                            break;
                        }
                    }

                    while (true)
                    {
                        Console.WriteLine("Please enter the Points for Post No {0}", i);

                        if (!ValidatePostInput.ValidatePoints(Console.ReadLine(), out Points, out error))
                        {
                            Console.WriteLine(error);
                        }
                        else
                        {
                            break;
                        }
                    }


                    while (true)
                    {
                        Console.WriteLine("Please enter the Comments for Post No {0}", i);

                        if (!ValidatePostInput.ValidateComments(Console.ReadLine(), out Comments, out error))
                        {
                            Console.WriteLine(error);
                        }
                        else
                        {
                            break;
                        }
                    }

                    while (true)
                    {
                        Console.WriteLine("Please enter the Rank for Post No {0}", i);

                        if (!ValidatePostInput.ValidateRank(Console.ReadLine(), out Rank, out error))
                        {
                            Console.WriteLine(error);
                        }
                        else
                        {
                            break;
                        }
                    }

                    Posts post = new Posts()
                    {
                        title    = Title,
                        uri      = uri,
                        author   = Author,
                        points   = Points,
                        comments = Comments,
                        rank     = Rank
                    };

                    postLogic.CreateList(post);
                }
                Console.WriteLine("JSON post is as follows...");
                Console.WriteLine(postLogic.CreateJSON());
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            Console.ReadKey();
        }
Example #30
0
 public FormPosts(PostLogic logic)
 {
     InitializeComponent();
     this.logic = logic;
 }