コード例 #1
0
        public void Setup()
        {
            var         config = GeneralHelpers.InitConfiguration();
            CommentRepo a      = new CommentRepo(config);

            _testRepo = a;
        }
コード例 #2
0
        public override void ExtraDelete(Task task)
        {
            LogWorkRepo repoWork    = new LogWorkRepo();
            CommentRepo repoComment = new CommentRepo();

            List <Comment> comments = repoComment.GetAll().ToList();
            List <LogWork> work     = repoWork.GetAll().ToList();

            foreach (Comment item in comments)
            {
                if (item.taskId == task.Id)
                {
                    repoComment.Delete(item);
                }
            }


            foreach (LogWork item in work)
            {
                if (item.TaskId == task.Id)
                {
                    repoWork.Delete(item);
                }
            }
        }
コード例 #3
0
        public override void ExtraDelete(User user)
        {
            TaskRepo    repoTask    = new TaskRepo();
            LogWorkRepo repoWork    = new LogWorkRepo();
            CommentRepo repoComment = new CommentRepo();

            List <Task>    tasks    = repoTask.GetAll(t => t.creatorId == user.Id).ToList();
            List <Comment> comments = repoComment.GetAll().ToList();
            List <LogWork> works    = repoWork.GetAll().ToList();

            foreach (Task item in tasks)
            {
                foreach (Comment comment in comments)
                {
                    if (comment.taskId == item.Id)
                    {
                        repoComment.Delete(comment);
                    }
                }

                foreach (LogWork work in works)
                {
                    if (work.TaskId == item.Id)
                    {
                        repoWork.Delete(work);
                    }
                }

                repoTask.Delete(item);
            }
        }
コード例 #4
0
        public ActionResult DeleteComment(DeleteCommentVM delete)
        {
            CommentRepo repo           = new CommentRepo();
            Comment     deletedComment = repo.GetById(Convert.ToInt32(delete.Id));

            repo.Delete(deletedComment);

            return(RedirectToAction("Details", "TaskManagement", new { id = Convert.ToInt32(deletedComment.taskId) }));
        }
コード例 #5
0
        public RedirectToActionResult AddComment(string commentText)
        {
            Comment stories = new Comment {
                AStoriesComments = commentText
            };

            CommentRepo.AddComment(stories);

            return(RedirectToAction("Index"));
        }
コード例 #6
0
        public Invoice_comments_membership getInvoice_comments(int i)
        {
            CommentRepo c_repo             = new CommentRepo();
            Invoice_comments_membership im = new Invoice_comments_membership
            {
                invoice_obj = invo.getInov(i),
                //  CommentsList =  c_repo.ListComment(i)
            };

            return(im);
        }
コード例 #7
0
        public ActionResult Details(int?id)
        {
            TaskDetailsVm model = new TaskDetailsVm();

            model.PagerComment      = model.PagerComment ?? new Pager();
            model.PagerLogWork      = model.PagerLogWork ?? new Pager();
            model.FilterComment     = model.FilterComment ?? new CommentsFilter();
            model.FilterLoggedWorks = model.FilterLoggedWorks ?? new LoggedWorksFilter();
            TryUpdateModel(model);

            TaskRepo repository = RepositoryFactory.GetTasksRepository();
            Task     task       = repository.GetById(Convert.ToInt32(id));

            model.Id              = task.Id;
            model.UserId          = task.UserId;
            model.Title           = task.Title;
            model.Description     = task.Description;
            model.ResponsibleUser = task.ResponsibleUser;
            model.Creator         = task.Creator;
            model.Status          = task.Status;
            model.LastChange      = task.LastChange;
            model.CreateTime      = task.CreateTime;

            CommentRepo    comRepo     = RepositoryFactory.GetCommentsRepository();
            LoggedWorkRepo logWorkRepo = RepositoryFactory.GetLoggedWorksRepository();

            string action     = this.ControllerContext.RouteData.Values["action"].ToString();
            string controller = this.ControllerContext.RouteData.Values["controller"].ToString();

            //comments
            model.FilterComment.Prefix = "FilterComment.";
            string commentsPrefix = "PagerComment.";

            model.FilterComment.TaskId = task.Id;
            int commentsResultCount = comRepo.Count(model.FilterComment.BuildFilter());

            model.PagerComment = new Pager(commentsResultCount, model.PagerComment.CurrentPage, model.PagerComment.PageSize, commentsPrefix, action, controller);
            model.FilterComment.ParentPager = model.PagerComment;
            model.CommentsList = comRepo.GetAll(model.FilterComment.BuildFilter(), model.PagerComment.CurrentPage, model.PagerComment.PageSize.Value).ToList();

            //loggedwork
            model.FilterLoggedWorks.Prefix = "FilterLoggedWorks.";
            string loggedWorkPrefix = "PagerLogWork.";

            model.FilterLoggedWorks.TaskId = task.Id;
            int loggedWorkResultCount = logWorkRepo.Count(model.FilterLoggedWorks.BuildFilter());

            model.PagerLogWork = new Pager(loggedWorkResultCount, model.PagerLogWork.CurrentPage, model.PagerLogWork.PageSize, loggedWorkPrefix, action, controller);
            model.FilterLoggedWorks.ParentPager = model.PagerLogWork;
            model.LoggedWorkList = logWorkRepo.GetAll(model.FilterLoggedWorks.BuildFilter(), model.PagerLogWork.CurrentPage, model.PagerLogWork.PageSize.Value).ToList();

            return(View(model));
        }
コード例 #8
0
ファイル: HomeController.cs プロジェクト: PC-Pedia/Event
        public async Task <IActionResult> Index()
        {
            var model = new MainViewModel();

            model.User             = currentUser;
            model.EventSearchModel = Search(model.EventSearchModel);

            model.Purchases = await PurchaseRepp.GetAll().Where(x => x.UserId == currentUser.Id).ToListAsync();

            model.Comments = await CommentRepo.GetAll().Where(x => x.UserId == currentUser.Id).ToListAsync();

            return(View(model));
        }
コード例 #9
0
        protected void btnSendReply_Click(object sender, EventArgs e)
        {
            int     parentId = Convert.ToInt32(fcommentId.Value);
            int     postId   = Convert.ToInt32(fpostId.Value);
            string  content  = txtReply.Text;
            int     userId   = Convert.ToInt32(Session["UserId"].ToString());
            Comment comment  = new Comment {
                PostId = postId, Content = content, ParentId = parentId, UserId = userId
            };

            CommentRepo.InsertComment(comment);
            Response.Redirect($"/posts/{postId}/");
        }
コード例 #10
0
        protected void Page_Load(object sender, EventArgs e)
        {
            // Assigning the ID of the post to postId variable.
            int.TryParse(Page.RouteData.Values["Id"].ToString(), out int postId);
            postID = postId;

            // Setting the comment section disabled if the user is not logged in.
            if (Session["UserId"] != null)
            {
                userID = Convert.ToInt32(Session["UserId"]);
            }
            else
            {
                txtComment.Enabled = false;
            }

            //Gets the  specific post the user have clicked
            userPost = Repositories.PostRepo.GetPost(postId);
            if (userPost.PostId == 0)
            {
                Response.Redirect("/NotFoundPage.aspx");
            }
            user         = Repositories.UserRepo.GetUser(userPost.UserId);
            lbTitle.Text = userPost.Title;
            ShowPost();

            // POSTID
            List <Comment> comments = CommentRepo.GetComments(postId);

            CommentSection.Comments = comments;

            // Fetching recent posts
            posts = Repositories.PostRepo.GetPosts();
            var btns = new List <Button>
            {
                btnPost1, btnPost2, btnPost3, btnPost4, btnPost5
            };

            for (int i = 0; i < posts.Count && i < 5; i++)
            {
                btns[i].Text = posts[i].Category + ": " + posts[i].Title;
                //btnPost1.Text = posts[0].Category + ": " + posts[0].Title;
                //btnPost2.Text = posts[1].Category + ": " + posts[1].Title;
                //btnPost3.Text = posts[2].Category + ": " + posts[2].Title;
                //btnPost4.Text = posts[3].Category + ": " + posts[3].Title;
                //btnPost5.Text = posts[4].Category + ": " + posts[4].Title;
            }
        }
コード例 #11
0
        protected override void DeleteFilter(int id)
        {
            CommentRepo    comRepository = RepositoryFactory.GetCommentsRepository();
            List <Comment> comments      = comRepository.GetAll().FindAll(com => com.TaskId == id);

            foreach (var com in comments)
            {
                comRepository.Delete(com);
            }
            LoggedWorkRepo    loggedWorkRepo = RepositoryFactory.GetLoggedWorksRepository();
            List <LoggedWork> loggedWorks    = loggedWorkRepo.GetAll().FindAll(lw => lw.TaskId == id);

            foreach (var lw in loggedWorks)
            {
                loggedWorkRepo.Delete(lw);
            }
        }
コード例 #12
0
        public ActionResult CreateComment(CreateCommentVM create)
        {
            if (!this.ModelState.IsValid)
            {
                return(View(create));
            }

            CommentRepo commentRepo = new CommentRepo();
            Comment     newComment  = new Comment();

            newComment.commentTittle    = create.Tittle;
            newComment.commentContent   = create.Content;
            newComment.Date             = DateTime.Now;
            newComment.commentCreatorId = AuthenticationManager.LoggedUser.Id;
            newComment.taskId           = create.TaskId;

            commentRepo.Create(newComment);

            return(RedirectToAction("Details", "TaskManagement", new { id = create.TaskId }));
        }
コード例 #13
0
        public ActionResult DeleteComment(int id)
        {
            if (AuthenticationManager.LoggedUser == null)
            {
                return(RedirectToAction("Login", "Home"));
            }

            CommentRepo repoComment = new CommentRepo();
            Comment     comment     = repoComment.GetById(id);

            TaskRepo repo = new TaskRepo();
            Task     task = repo.GetById(comment.taskId);


            if (comment.commentCreatorId == AuthenticationManager.LoggedUser.Id || task.creatorId == AuthenticationManager.LoggedUser.Id)
            {
                UserRepo    repoUser = new UserRepo();
                List <User> users    = repoUser.GetAll().ToList();

                DeleteCommentVM delete = new DeleteCommentVM();
                delete.users = new List <User>();

                delete.Id        = comment.Id;
                delete.Tittle    = comment.commentTittle;
                delete.Content   = comment.commentContent;
                delete.CreatorId = comment.commentCreatorId;
                delete.TaskId    = comment.taskId;
                delete.Date      = comment.Date;

                foreach (var item in users)
                {
                    delete.users.Add(item);
                }

                return(View(delete));
            }
            else
            {
                return(RedirectToAction("Details", "TaskManagement", new { id = comment.taskId }));
            }
        }
コード例 #14
0
        public void CreateCommentTest()
        {
            var repo    = new CommentRepo();
            var comment = new Comment()
            {
                BlogPostID     = 1,
                CommentContent = "This is a comment test",
                Status         = new Status()
                {
                    StatusID = 1
                },
                User     = new User(),
                Nickname = "Jake"
            };

            repo.CreateComment(comment);

            var list = repo.GetAllCommentsByPostID(1);

            Assert.AreEqual(1, list.Count);
        }
コード例 #15
0
        protected override void DeleteFilter(int id)
        {
            TaskRepo    taskRepository = RepositoryFactory.GetTasksRepository();
            List <Task> tasks          = taskRepository.GetAll().FindAll(task => task.UserId == id && task.ResponsibleUser == id);

            foreach (var task in tasks)
            {
                taskRepository.Delete(task);
            }

            List <Task> tasksRespU = taskRepository.GetAll();

            foreach (var task in tasksRespU)
            {
                if (task.ResponsibleUser == AuthenticationManager.LoggedUser.Id)
                {
                    task.UserId = AuthenticationManager.LoggedUser.Id;

                    taskRepository.Save(task);
                }
            }

            CommentRepo    comRepository = RepositoryFactory.GetCommentsRepository();
            List <Comment> comments      = comRepository.GetAll().FindAll(com => com.CreatedBy == id);

            foreach (var com in comments)
            {
                comRepository.Delete(com);
            }

            LoggedWorkRepo    loggedWorkRepo = RepositoryFactory.GetLoggedWorksRepository();
            List <LoggedWork> loggedWorks    = loggedWorkRepo.GetAll().FindAll(lw => lw.UserId == id);

            foreach (var lw in loggedWorks)
            {
                loggedWorkRepo.Delete(lw);
            }
        }
コード例 #16
0
        private void GetAllComments(Entities.Task task)
        {
            var         logedUser = AuthenticationService.LoggedUser;
            CommentRepo repo      = new CommentRepo("comments.txt");
            var         coms      = repo.GetAll();

            Console.Clear();
            foreach (var com in coms)
            {
                if (com.ParentId == task.Id)
                {
                    Console.Write("Created by ID: ");
                    Console.WriteLine(com.CreatedBy);
                    Console.Write("Comments: ");
                    Console.WriteLine(com.Comments);
                    Console.WriteLine("###############################");
                }
            }
            Console.ReadKey();
            Console.Clear();
            DetailMenuVIew detailMenu = new DetailMenuVIew();

            detailMenu.PrintRepo(task);
        }
コード例 #17
0
        internal void AddComment(Entities.Task task)
        {
            Console.Clear();
            CommentRepo repo = new CommentRepo("comments.txt");
            Comment     com  = new Comment();

            Console.WriteLine("***************************");
            Console.WriteLine("***** ADD NEW COMMENT *****");
            Console.Write("Comment: ");
            com.Comments  = Console.ReadLine();
            com.ParentId  = Convert.ToInt32(task.Id);
            com.CreatedBy = Convert.ToInt32(AuthenticationService.LoggedUser.Id);
            repo.Save(com);
            Console.Clear();
            Console.WriteLine("*******************************");
            Console.WriteLine("********* COMPLETED!!! ********");
            Console.WriteLine("*******************************");
            Thread.Sleep(1500);
            Console.Clear();

            DetailMenuVIew detailMenu = new DetailMenuVIew();

            detailMenu.PrintRepo(task);
        }
コード例 #18
0
        static async Task PopulateDatabase()
        {
            // admin
            AccountRepo  accountRepo = new AccountRepo();
            AccountModel admin       = new AccountModel()
            {
                Username = "******",
                Password = "******",
                Name     = "boss"
            };
            await accountRepo.CreateAccount(admin);

            ComponentRepo componentRepo = new ComponentRepo();
            BuildRepo     buildRepo     = new BuildRepo();


            //accounts
            AccountModel dummy1 = new AccountModel()
            {
                Username = "******",
                Password = "******",
                Name     = "test1"
            };
            AccountModel dummy2 = new AccountModel()
            {
                Username = "******",
                Password = "******",
                Name     = "test2"
            };
            await accountRepo.CreateAccount(dummy1);

            await accountRepo.CreateAccount(dummy2);


            //procesoare
            ComponentModel proc1 = new ComponentModel()
            {
                Name              = "Ryzen 7 5800X",
                Brand             = "AMD",
                ReleaseYear       = "2020",
                Type              = "CPU",
                SocketType        = "AM4",
                EnergyConsumption = 105,
                AdditionalInfo    = "3,8 GHz up to 4.7 GHz, 8 cores, 16 threads"
            };
            ComponentModel proc2 = new ComponentModel()
            {
                Name              = "Ryzen 9 5950X",
                Brand             = "AMD",
                ReleaseYear       = "2020",
                Type              = "CPU",
                SocketType        = "AM4",
                EnergyConsumption = 105,
                AdditionalInfo    = "3.4 GHz up to 4.9 GHz, 16 cores, 32 threads"
            };
            ComponentModel proc3 = new ComponentModel()
            {
                Name              = "Ryzen 9 5900X",
                Brand             = "AMD",
                ReleaseYear       = "2020",
                Type              = "CPU",
                SocketType        = "AM4",
                EnergyConsumption = 105,
                AdditionalInfo    = "3.7 GHz up to 4.8 GHz, 12 cores, 24 threads"
            };
            ComponentModel proc4 = new ComponentModel()
            {
                Name              = "Ryzen 5 5600X",
                Brand             = "AMD",
                ReleaseYear       = "2020",
                Type              = "CPU",
                SocketType        = "AM4",
                EnergyConsumption = 65,
                AdditionalInfo    = "3.7 GHz up to 4.6 GHz, 6 cores, 12 threads"
            };
            ComponentModel proc5 = new ComponentModel()
            {
                Name              = "i9-10850K",
                Brand             = "Intel",
                ReleaseYear       = "2020",
                Type              = "CPU",
                SocketType        = "1200 LGA",
                EnergyConsumption = 125,
                AdditionalInfo    = "3.6 GHz up to 5.2 GHz, 10 cores, 20 threads"
            };
            ComponentModel proc6 = new ComponentModel()
            {
                Name              = "i9-10900T",
                Brand             = "Intel",
                ReleaseYear       = "2020",
                Type              = "CPU",
                SocketType        = "1200 LGA",
                EnergyConsumption = 35,
                AdditionalInfo    = "1.9 GHz up to 4.6 GHz, 10 cores, 20 threads"
            };
            ComponentModel proc7 = new ComponentModel()
            {
                Name              = "i9-10900",
                Brand             = "Intel",
                ReleaseYear       = "2020",
                Type              = "CPU",
                SocketType        = "1200 LGA",
                EnergyConsumption = 65,
                AdditionalInfo    = "2.8 GHz up to 5.2 GHz, 10 cores, 20 threads"
            };
            ComponentModel proc8 = new ComponentModel()
            {
                Name              = "i9-10900K",
                Brand             = "Intel",
                ReleaseYear       = "2020",
                Type              = "CPU",
                SocketType        = "1200 LGA",
                EnergyConsumption = 125,
                AdditionalInfo    = "3.7 GHz up to 5.3 GHz, 10 cores, 20 threads"
            };
            ComponentModel proc9 = new ComponentModel()
            {
                Name              = "i9-10980HK",
                Brand             = "Intel",
                ReleaseYear       = "2020",
                Type              = "CPU",
                SocketType        = "1440 BGA",
                EnergyConsumption = 45,
                AdditionalInfo    = "2.4 GHz up to 5.3 GHz, 8 cores, 16 threads"
            };

            await componentRepo.CreateComponent(proc1);

            await componentRepo.CreateComponent(proc2);

            await componentRepo.CreateComponent(proc3);

            await componentRepo.CreateComponent(proc4);

            await componentRepo.CreateComponent(proc5);

            await componentRepo.CreateComponent(proc6);

            await componentRepo.CreateComponent(proc7);

            await componentRepo.CreateComponent(proc8);

            await componentRepo.CreateComponent(proc9);

            // placi video
            ComponentModel gpu1 = new ComponentModel()
            {
                Name              = "Radeon RX 6800",
                Brand             = "AMD",
                ReleaseYear       = "2020",
                Type              = "GPU",
                SocketType        = "PCIe 4.0 x16",
                EnergyConsumption = 250,
                AdditionalInfo    = "1815 MHz, 16 GB GDDR6, 256 bit"
            };
            ComponentModel gpu2 = new ComponentModel()
            {
                Name              = "Radeon RX 6800 XT",
                Brand             = "AMD",
                ReleaseYear       = "2020",
                Type              = "GPU",
                SocketType        = "PCIe 4.0 x16",
                EnergyConsumption = 300,
                AdditionalInfo    = "2015 MHz, 16 GB GDDR6, 256 bit"
            };
            ComponentModel gpu3 = new ComponentModel()
            {
                Name              = "Radeon RX 6900 XT",
                Brand             = "AMD",
                ReleaseYear       = "2020",
                Type              = "GPU",
                SocketType        = "PCIe 4.0 x16",
                EnergyConsumption = 300,
                AdditionalInfo    = "2015 MHz, 16 GB GDDR6, 256 bit"
            };
            ComponentModel gpu4 = new ComponentModel()
            {
                Name              = "GeForce RTX 3090",
                Brand             = "NVIDIA",
                ReleaseYear       = "2020",
                Type              = "GPU",
                SocketType        = "PCIe 4.0 x16",
                EnergyConsumption = 350,
                AdditionalInfo    = "1400 MHz, 24 GB GDDR6X, 384 bit"
            };
            ComponentModel gpu5 = new ComponentModel()
            {
                Name              = "GeForce RTX 3080",
                Brand             = "NVIDIA",
                ReleaseYear       = "2020",
                Type              = "GPU",
                SocketType        = "PCIe 4.0 x16",
                EnergyConsumption = 320,
                AdditionalInfo    = "1440 MHz, 10 GB GDDR6X, 320 bit"
            };
            ComponentModel gpu6 = new ComponentModel()
            {
                Name              = "GeForce RTX 3070",
                Brand             = "NVIDIA",
                ReleaseYear       = "2020",
                Type              = "GPU",
                SocketType        = "PCIe 4.0 x16",
                EnergyConsumption = 220,
                AdditionalInfo    = "1500 MHz, 8 GB GDDR6, 256 bit"
            };
            ComponentModel gpu7 = new ComponentModel()
            {
                Name              = "GeForce RTX 3060 Ti",
                Brand             = "NVIDIA",
                ReleaseYear       = "2020",
                Type              = "GPU",
                SocketType        = "PCIe 4.0 x16",
                EnergyConsumption = 200,
                AdditionalInfo    = "1500 MHz, 8 GB GDDR6, 256 bit"
            };

            await componentRepo.CreateComponent(gpu1);

            await componentRepo.CreateComponent(gpu2);

            await componentRepo.CreateComponent(gpu3);

            await componentRepo.CreateComponent(gpu4);

            await componentRepo.CreateComponent(gpu5);

            await componentRepo.CreateComponent(gpu6);

            await componentRepo.CreateComponent(gpu7);


            // memorie RAM
            ComponentModel ram1 = new ComponentModel()
            {
                Name              = "ValueRam KVR13N9K2/16",
                Brand             = "Kingston",
                ReleaseYear       = "2015",
                Type              = "RAM",
                SocketType        = "DDR3",
                EnergyConsumption = 0,
                AdditionalInfo    = "2x8GB kit, DDR3-1333 CL9"
            };
            ComponentModel ram2 = new ComponentModel()
            {
                Name              = "Viper Elite Gray",
                Brand             = "Patriot",
                ReleaseYear       = "2019",
                Type              = "RAM",
                SocketType        = "DDR4",
                EnergyConsumption = 0,
                AdditionalInfo    = "2x4GB kit, DDR4-2666 CL16"
            };
            ComponentModel ram3 = new ComponentModel()
            {
                Name              = "VENGEANCE RGB PRO 16",
                Brand             = "Corsair",
                ReleaseYear       = "2018",
                Type              = "RAM",
                SocketType        = "DDR4",
                EnergyConsumption = 0,
                AdditionalInfo    = "2x8GB kit, DDR4-3000 CL15"
            };
            ComponentModel ram4 = new ComponentModel()
            {
                Name              = "ValueRam KVR16S11K2/16",
                Brand             = "Kingston",
                ReleaseYear       = "2015",
                Type              = "RAM",
                SocketType        = "DDR3",
                EnergyConsumption = 0,
                AdditionalInfo    = "2x8GB kit, DDR3-1600 CL11"
            };
            ComponentModel ram5 = new ComponentModel()
            {
                Name              = "Premier 16",
                Brand             = "ADATA",
                ReleaseYear       = "2016",
                Type              = "RAM",
                SocketType        = "DDR4",
                EnergyConsumption = 0,
                AdditionalInfo    = "2x8GB kit, DDR4-2400 CL17"
            };
            ComponentModel ram6 = new ComponentModel()
            {
                Name              = "XPG Gammix D10",
                Brand             = "ADATA",
                ReleaseYear       = "2018",
                Type              = "RAM",
                SocketType        = "DDR4",
                EnergyConsumption = 0,
                AdditionalInfo    = "2x8GB kit, DDR4-3200 CL16"
            };
            ComponentModel ram7 = new ComponentModel()
            {
                Name              = "Fury RGB",
                Brand             = "HyperX",
                ReleaseYear       = "2019",
                Type              = "RAM",
                SocketType        = "DDR4",
                EnergyConsumption = 0,
                AdditionalInfo    = "2x16GB kit, DDR4-3200 CL16"
            };
            ComponentModel ram8 = new ComponentModel()
            {
                Name              = "Viper 4",
                Brand             = "Patriot",
                ReleaseYear       = "2019",
                Type              = "RAM",
                SocketType        = "DDR4",
                EnergyConsumption = 0,
                AdditionalInfo    = "2x16GB kit, DDR4-3000 CL16"
            };
            await componentRepo.CreateComponent(ram1);

            await componentRepo.CreateComponent(ram2);

            await componentRepo.CreateComponent(ram3);

            await componentRepo.CreateComponent(ram4);

            await componentRepo.CreateComponent(ram5);

            await componentRepo.CreateComponent(ram6);

            await componentRepo.CreateComponent(ram7);

            await componentRepo.CreateComponent(ram8);


            //storage
            ComponentModel stor1 = new ComponentModel()
            {
                Name              = "P300 HDD",
                Brand             = "Toshiba",
                ReleaseYear       = "2018",
                Type              = "Storage",
                SocketType        = "SATA-III",
                EnergyConsumption = 0,
                AdditionalInfo    = "2TB, 7200rpm, 64MB buffer, 3.5inch"
            };
            ComponentModel stor2 = new ComponentModel()
            {
                Name              = "BarraCuda HDD",
                Brand             = "Seagate",
                ReleaseYear       = "2018",
                Type              = "Storage",
                SocketType        = "SATA-III",
                EnergyConsumption = 0,
                AdditionalInfo    = "1TB, 7200 rpm, 64MB buffer, 3.5inch"
            };
            ComponentModel stor3 = new ComponentModel()
            {
                Name              = "Blue HDD",
                Brand             = "WD",
                ReleaseYear       = "2019",
                Type              = "Storage",
                SocketType        = "SATA-III",
                EnergyConsumption = 0,
                AdditionalInfo    = "1TB, 7200 rpm, 64MB buffer, 3.5inch"
            };
            ComponentModel stor4 = new ComponentModel()
            {
                Name              = "P2 SSD",
                Brand             = "Crucial",
                ReleaseYear       = "2017",
                Type              = "Storage",
                SocketType        = "NVMe",
                EnergyConsumption = 0,
                AdditionalInfo    = "500GB, 940MB/s - 2300MB/s, M.2"
            };
            ComponentModel stor5 = new ComponentModel()
            {
                Name              = "A400 SSD",
                Brand             = "Kingston",
                ReleaseYear       = "2018",
                Type              = "Storage",
                SocketType        = "SATA-III",
                EnergyConsumption = 0,
                AdditionalInfo    = "240GB, 350MB/s - 500MB/s, 2.5inch"
            };
            await componentRepo.CreateComponent(stor1);

            await componentRepo.CreateComponent(stor2);

            await componentRepo.CreateComponent(stor3);

            await componentRepo.CreateComponent(stor4);

            await componentRepo.CreateComponent(stor5);


            //power supply
            ComponentModel supply1 = new ComponentModel()
            {
                Name              = "S12III-550",
                Brand             = "Seasonic",
                ReleaseYear       = "2018",
                Type              = "Power supply",
                SocketType        = "",
                EnergyConsumption = 550,
                AdditionalInfo    = "85%, 80+ Bronze"
            };
            ComponentModel supply2 = new ComponentModel()
            {
                Name              = "CV650",
                Brand             = "Corsair",
                ReleaseYear       = "2019",
                Type              = "Power supply",
                SocketType        = "",
                EnergyConsumption = 650,
                AdditionalInfo    = "88%, 80+ Bronze"
            };
            ComponentModel supply3 = new ComponentModel()
            {
                Name              = "System Power 9 500",
                Brand             = "bequiet!",
                ReleaseYear       = "2020",
                Type              = "Power supply",
                SocketType        = "",
                EnergyConsumption = 500,
                AdditionalInfo    = "88%, 80+ Bronze"
            };
            ComponentModel supply4 = new ComponentModel()
            {
                Name              = "Power Zone 850",
                Brand             = "bequiet!",
                ReleaseYear       = "2020",
                Type              = "Power supply",
                SocketType        = "",
                EnergyConsumption = 850,
                AdditionalInfo    = "88%, 80+ Bronze"
            };
            ComponentModel supply5 = new ComponentModel()
            {
                Name              = "MWE GOLD 650",
                Brand             = "Cooler Master",
                ReleaseYear       = "2019",
                Type              = "Power supply",
                SocketType        = "",
                EnergyConsumption = 650,
                AdditionalInfo    = "90%, 80+ Gold, Modular"
            };
            ComponentModel supply6 = new ComponentModel()
            {
                Name              = "C750",
                Brand             = "NZXT",
                ReleaseYear       = "2019",
                Type              = "Power supply",
                SocketType        = "",
                EnergyConsumption = 750,
                AdditionalInfo    = "90%, 80+ Gold, Modular"
            };
            await componentRepo.CreateComponent(supply1);

            await componentRepo.CreateComponent(supply2);

            await componentRepo.CreateComponent(supply3);

            await componentRepo.CreateComponent(supply4);

            await componentRepo.CreateComponent(supply5);

            await componentRepo.CreateComponent(supply6);


            //placi de baza
            ComponentModel mb1 = new ComponentModel()
            {
                Name              = "B365M PRO-VH",
                Brand             = "MSI",
                ReleaseYear       = "2018",
                Type              = "Motherboard",
                SocketType        = "1151v2, PCIe 3.0 x16, DDR4, SATA-III",
                EnergyConsumption = 0,
                AdditionalInfo    = "mATX"
            };
            ComponentModel mb2 = new ComponentModel()
            {
                Name              = "PRIME B460-PLUS",
                Brand             = "ASUS",
                ReleaseYear       = "2020",
                Type              = "Motherboard",
                SocketType        = "1200 LGA, PCIe 4.0 x16, DDR4, SATA-III, NVMe",
                EnergyConsumption = 0,
                AdditionalInfo    = "ATX"
            };
            ComponentModel mb3 = new ComponentModel()
            {
                Name              = "B450 AORUS ELITE",
                Brand             = "GIGABYTE",
                ReleaseYear       = "2019",
                Type              = "Motherboard",
                SocketType        = "AM4, PCIe 3.0 x16, DDR4, SATA-III",
                EnergyConsumption = 0,
                AdditionalInfo    = "ATX"
            };
            ComponentModel mb4 = new ComponentModel()
            {
                Name              = "X570-A PRO",
                Brand             = "MSI",
                ReleaseYear       = "2020",
                Type              = "Motherboard",
                SocketType        = "AM4, PCIe 4.0 x16, DDR4, SATA-III, NVMe",
                EnergyConsumption = 0,
                AdditionalInfo    = "ATX"
            };
            ComponentModel mb5 = new ComponentModel()
            {
                Name              = "Z490-A PRO",
                Brand             = "MSI",
                ReleaseYear       = "2018",
                Type              = "Motherboard",
                SocketType        = "1200 LGA, PCIe 3.0 x16, DDR4, SATA-III",
                EnergyConsumption = 0,
                AdditionalInfo    = "ATX"
            };
            await componentRepo.CreateComponent(mb1);

            await componentRepo.CreateComponent(mb2);

            await componentRepo.CreateComponent(mb3);

            await componentRepo.CreateComponent(mb4);

            await componentRepo.CreateComponent(mb5);


            // gpu pcie 3
            ComponentModel pcie1 = new ComponentModel()
            {
                Name              = "GeForce GTX 1650",
                Brand             = "NVIDIA",
                ReleaseYear       = "2019",
                Type              = "GPU",
                SocketType        = "PCIe 3.0 x16",
                EnergyConsumption = 75,
                AdditionalInfo    = "1485 MHz, 4 GB GDDR5, 128 bit"
            };
            ComponentModel pcie2 = new ComponentModel()
            {
                Name              = "GeForce RTX 2060",
                Brand             = "NVIDIA",
                ReleaseYear       = "2018",
                Type              = "GPU",
                SocketType        = "PCIe 3.0 x16",
                EnergyConsumption = 160,
                AdditionalInfo    = "1365 MHz, 6 GB GDDR6, 192 bit"
            };
            await componentRepo.CreateComponent(pcie1);

            await componentRepo.CreateComponent(pcie2);


            // cpu 1151v2
            ComponentModel cpuaa = new ComponentModel()
            {
                Name              = "i5-9600K",
                Brand             = "Intel",
                ReleaseYear       = "2018",
                Type              = "CPU",
                SocketType        = "1151v2",
                EnergyConsumption = 95,
                AdditionalInfo    = "3.7 GHz up to 4.6 GHz, 6 cores, 6 threads"
            };
            ComponentModel cpubb = new ComponentModel()
            {
                Name              = "i7-9700K",
                Brand             = "Intel",
                ReleaseYear       = "2018",
                Type              = "CPU",
                SocketType        = "1151v2",
                EnergyConsumption = 95,
                AdditionalInfo    = "3.6 GHz up to 4.9 GHz, 8 cores, 8 threads"
            };
            await componentRepo.CreateComponent(cpuaa);

            await componentRepo.CreateComponent(cpubb);



            // prebuilds
            // p1
            ComponentModel pb1c1 = new ComponentModel()
            {
                Name              = "i3-9100",
                Brand             = "Intel",
                ReleaseYear       = "2019",
                Type              = "CPU",
                SocketType        = "1151v2",
                EnergyConsumption = 65,
                AdditionalInfo    = "3.6 GHz up to 4.2 GHz, 4 cores, 4 threads"
            };
            ComponentModel pb1c2 = new ComponentModel()
            {
                Name              = "H310M PRO-M2 PLUS",
                Brand             = "MSI",
                ReleaseYear       = "2019",
                Type              = "Motherboard",
                SocketType        = "1151v2, PCIe 3.0 x16, DDR4, SATA-III",
                EnergyConsumption = 0,
                AdditionalInfo    = "mATX"
            };
            ComponentModel pb1c3 = new ComponentModel()
            {
                Name              = "Fury Black",
                Brand             = "HyperX",
                ReleaseYear       = "2018",
                Type              = "RAM",
                SocketType        = "DDR4",
                EnergyConsumption = 0,
                AdditionalInfo    = "2x8GB kit, DDR4-2400 CL15"
            };
            ComponentModel pb1c4 = new ComponentModel()
            {
                Name              = "High Performance SSD",
                Brand             = "Intenso",
                ReleaseYear       = "2018",
                Type              = "Storage",
                SocketType        = "SATA-III",
                EnergyConsumption = 0,
                AdditionalInfo    = "480GB, 520MB/s - 500MB/s, 2.5inch"
            };
            ComponentModel pb1c5 = new ComponentModel()
            {
                Name              = "FL500-12",
                Brand             = "Floston",
                ReleaseYear       = "2015",
                Type              = "Power supply",
                SocketType        = "",
                EnergyConsumption = 500,
                AdditionalInfo    = "Not certified"
            };
            await componentRepo.CreateComponent(pb1c1);

            await componentRepo.CreateComponent(pb1c2);

            await componentRepo.CreateComponent(pb1c3);

            await componentRepo.CreateComponent(pb1c4);

            await componentRepo.CreateComponent(pb1c5);

            IList <ComponentModel> list1 = new Collection <ComponentModel>();

            list1.Add(await componentRepo.GetComponentByName("i3-9100"));
            list1.Add(await componentRepo.GetComponentByName("H310M PRO-M2 PLUS"));
            list1.Add(await componentRepo.GetComponentByName("Fury Black"));
            list1.Add(await componentRepo.GetComponentByName("High Performance SSD"));
            list1.Add(await componentRepo.GetComponentByName("FL500-12"));
            BuildModel pre1 = new BuildModel()
            {
                AccountModelUserId = 1,
                Name          = "Office Computer",
                ComponentList = list1
            };
            await buildRepo.CreateBuild(pre1);

            // p2
            ComponentModel pb2c4 = new ComponentModel()
            {
                Name              = "Red Pro HDD",
                Brand             = "WD",
                ReleaseYear       = "2019",
                Type              = "Storage",
                SocketType        = "SATA-III",
                EnergyConsumption = 0,
                AdditionalInfo    = "4TB, 7200 rpm, 256MB buffer, 3.5inch"
            };
            await componentRepo.CreateComponent(pb2c4);

            IList <ComponentModel> list2 = new Collection <ComponentModel>();

            list2.Add(await componentRepo.GetComponentByName("Ryzen 7 5800X"));  //5800x
            list2.Add(await componentRepo.GetComponentByName("Radeon RX 6800")); //6800
            list2.Add(await componentRepo.GetComponentByName("X570-A PRO"));     //msi x570
            list2.Add(await componentRepo.GetComponentByName("Viper 4"));        //patriot
            list2.Add(await componentRepo.GetComponentByName("CV650"));          //corsair
            list2.Add(await componentRepo.GetComponentByName("Red Pro HDD"));    //wd 4tb
            BuildModel pre2 = new BuildModel()
            {
                AccountModelUserId = 1,
                Name          = "Workstation Computer",
                ComponentList = list2
            };
            await buildRepo.CreateBuild(pre2);

            // p3
            IList <ComponentModel> list3 = new Collection <ComponentModel>();

            list3.Add(await componentRepo.GetComponentByName("i9-10900K"));        //10900k
            list3.Add(await componentRepo.GetComponentByName("GeForce RTX 3090")); //3090
            list3.Add(await componentRepo.GetComponentByName("PRIME B460-PLUS"));  //asus b460
            list3.Add(await componentRepo.GetComponentByName("Fury RGB"));         //hyperx rgb
            list3.Add(await componentRepo.GetComponentByName("Blue HDD"));         //wd blue
            list3.Add(await componentRepo.GetComponentByName("C750"));             //nzxt
            BuildModel pre3 = new BuildModel()
            {
                AccountModelUserId = 1,
                Name          = "Gaming Computer",
                ComponentList = list3
            };
            await buildRepo.CreateBuild(pre3);


            //posts
            PostRepo  postRepo = new PostRepo();
            PostModel p1       = new PostModel()
            {
                AccountModelUserId = 2,
                Content            = "The United States Declaration of Independence (formally The unanimous Declaration of the thirteen united States of America) is the pronouncement adopted by the Second Continental Congress meeting in Philadelphia, Pennsylvania, on July 4, 1776.",
            };
            PostModel p2 = new PostModel()
            {
                AccountModelUserId = 2,
                Content            = "During his youth, Alexander was tutored by Aristotle until age 16. After Philip's assassination in 336 BC, he succeeded his father to the throne and inherited a strong kingdom and an experienced army."
            };
            PostModel p3 = new PostModel()
            {
                AccountModelUserId = 3,
                Content            = "Night City is an American megacity in the Free State of North California, controlled by corporations and unassailed by the laws of both country and state. It sees conflict from rampant gang wars and its ruling entities contending for dominance."
            };
            await postRepo.CreatePost(p1);

            await postRepo.CreatePost(p2);

            await postRepo.CreatePost(p3);


            //comments
            CommentRepo  commentRepo = new CommentRepo();
            CommentModel c1          = new CommentModel()
            {
                AccountModelUserId = 3,
                Content            = "The most famous Egyptian pyramids are those found at Giza, on the outskirts of Cairo. Several of the Giza pyramids are counted among the largest structures ever built. The Pyramid of Khufu is the largest Egyptian pyramid.",
                PostModelId        = 1
            };
            CommentModel c2 = new CommentModel()
            {
                AccountModelUserId = 2,
                Content            = "As the tanuki, the animal has been significant in Japanese folklore since ancient times. The legendary tanuki is reputed to be mischievous and jolly, a master of disguise and shapeshifting, but somewhat gullible and absentminded.",
                PostModelId        = 3
            };
            await commentRepo.CreateComment(c1);

            await commentRepo.CreateComment(c2);
        }
コード例 #19
0
 public GalleryController()
 {
     photoRepository   = new PhotoRepository();
     commentRepository = new CommentRepo();
 }
コード例 #20
0
 public CommentBusinessRules(CommentRepo commentRepo)
 {
     _CommentRepo = commentRepo;
 }
コード例 #21
0
 public CommentController(IConfiguration config, ILogger <CommentController> log)
 {
     CommentRepo = new CommentRepo(config);
     _log        = log;
 }
コード例 #22
0
 public CommentService()
 {
     _comments = new CommentRepo();
 }
コード例 #23
0
        public ActionResult Details(int id)
        {
            TaskRepo repo = new TaskRepo();
            Task     task = repo.GetById(id);

            if (task.assignetId != AuthenticationManager.LoggedUser.Id && task.creatorId != AuthenticationManager.LoggedUser.Id)
            {
                return(RedirectToAction("Index", "TaskManagement"));
            }

            DetailsTaskVM model = new DetailsTaskVM();

            model.CommentsVM   = new ListCommentVM();
            model.LoggedWorkVM = new ListLogVM();

            UserRepo    repoUser = new UserRepo();
            List <User> users    = repoUser.GetAll().ToList();

            CommentRepo    repoComment = new CommentRepo();
            List <Comment> comments    = repoComment.GetAll(c => c.taskId == id).ToList();

            LogWorkRepo    repoWork = new LogWorkRepo();
            List <LogWork> works    = repoWork.GetAll(w => w.TaskId == id).ToList();

            model.Id           = task.Id;
            model.Tittle       = task.tittle;
            model.Content      = task.content;
            model.WorkingHours = task.estimate;
            model.AssigneeId   = task.assignetId;
            model.CreatorId    = task.creatorId;
            model.CreateOn     = task.createdON;
            model.EditedBy     = task.editedBY;
            model.EditedOn     = task.editedON;
            model.Status       = task.finnished;

            model.users = new List <User>();
            foreach (User item in users)
            {
                model.users.Add(item);
            }

            model.CommentsVM.Items = new List <Comment>();
            foreach (Comment item in comments)
            {
                model.CommentsVM.Items.Add(item);
            }

            model.LoggedWorkVM.Items = new List <LogWork>();
            foreach (LogWork item in works)
            {
                model.LoggedWorkVM.Items.Add(item);
            }

            model.CommentsVM.Pager         = new PagerVM();
            model.CommentsVM.Filter        = new CommentFilterVM();
            model.CommentsVM.Pager.Prefix  = "CommentsVM.Pager.";
            model.CommentsVM.Filter.Prefix = "CommentsVM.Filter.";
            model.CommentsVM.Filter.Pager  = model.CommentsVM.Pager;

            model.LoggedWorkVM.Pager         = new PagerVM();
            model.LoggedWorkVM.Filter        = new LogWorkFilterVM();
            model.LoggedWorkVM.Pager.Prefix  = "LoggedWorkVM.Pager.";
            model.LoggedWorkVM.Filter.Prefix = "LoggedWorkVM.Filter.";
            model.LoggedWorkVM.Filter.Pager  = model.LoggedWorkVM.Pager;

            TryUpdateModel(model);

            Expression <Func <Comment, bool> > commentFilter = model.CommentsVM.Filter.GenerateFilter();

            model.CommentsVM.Items = repoComment.GetAll(commentFilter, model.CommentsVM.Pager.CurrentPage, model.CommentsVM.Pager.PageSize).ToList();

            Expression <Func <LogWork, bool> > workFilter = model.LoggedWorkVM.Filter.GenerateFilter();

            model.LoggedWorkVM.Items = repoWork.GetAll(workFilter, model.LoggedWorkVM.Pager.CurrentPage, model.LoggedWorkVM.Pager.PageSize).ToList();

            model.CommentsVM.Pager.PagesCount = (int)Math.Ceiling(model.CommentsVM.Items.Count / (double)model.CommentsVM.Pager.PageSize);
            model.CommentsVM.Items            = model.CommentsVM.Items.Skip(model.CommentsVM.Pager.PageSize * (model.CommentsVM.Pager.CurrentPage - 1)).Take(model.CommentsVM.Pager.PageSize).ToList();

            model.LoggedWorkVM.Pager.PagesCount = (int)Math.Ceiling(model.LoggedWorkVM.Items.Count / (double)model.LoggedWorkVM.Pager.PageSize);
            model.LoggedWorkVM.Items            = model.LoggedWorkVM.Items.Skip(model.LoggedWorkVM.Pager.PageSize * (model.LoggedWorkVM.Pager.CurrentPage - 1)).Take(model.LoggedWorkVM.Pager.PageSize).ToList();

            return(View(model));
        }
コード例 #24
0
        void ShowPost()
        {
            // ------------------------ THIS IS FOR TIME -----------------------------------
            DateTime postedDate = userPost.CreatedAt;
            DateTime dateNow    = DateTime.Now;
            int      days       = Convert.ToInt32((dateNow - postedDate).TotalDays);
            int      hours      = Convert.ToInt32((dateNow - postedDate).TotalHours);
            int      minutes    = Convert.ToInt32((dateNow - postedDate).TotalMinutes);

            if (days == 0)
            {
                if (hours > 1)
                {
                    lblDate.Text = userPost.Category + " • Posted by " + user.Username + " " + hours + " hours ago";
                }
                else if (hours == 1)
                {
                    lblDate.Text = userPost.Category + " • Posted by " + user.Username + " " + hours + " hour ago";
                }
                else
                {
                    if (minutes > 1)
                    {
                        lblDate.Text = userPost.Category + " • Posted by " + user.Username + " " + minutes + " minutes ago";
                    }
                    else if (minutes == 1)
                    {
                        lblDate.Text = userPost.Category + " • Posted by " + user.Username + " " + minutes + " minute ago";
                    }
                    else
                    {
                        lblDate.Text = userPost.Category + " • Posted by " + user.Username + " " + " just now";
                    }
                }
            }
            else
            {
                if (days > 1)
                {
                    lblDate.Text = userPost.Category + " • Posted by " + user.Username + " " + " days ago";
                }
                else if (days == 1)
                {
                    lblDate.Text = userPost.Category + " • Posted by " + user.Username + " " + " day ago";
                }
            }

            // ----------------------- CONTENT -------------------------------------

            // IMAGE
            if (userPost.Image != null)
            {
                postImage.ImageUrl = "data:Image/png;base64," + userPost.Image;
                postImage.Visible  = true;
            }
            else
            {
                postImage.Visible  = false;
                postImage.CssClass = "noImage";
            }

            // CONTENT TEXT
            lblContentMessage.Text = userPost.Content.ToString();


            // Comment - CHANGE THE POSTID
            int commentCount = CommentRepo.commentCount(postID);

            if (commentCount > 1)
            {
                lblComment.Text = commentCount.ToString() + " Comments";
            }
            else
            {
                lblComment.Text = commentCount.ToString();
            }
        }
コード例 #25
0
 public CommentLogic(ICommentContext context)
 {
     commentRepo = new CommentRepo(context);
 }
コード例 #26
0
 Program()
 {
     context     = new TweetContext();
     commentRepo = new CommentRepo(context);
     postRepo    = new PostRepo(context);
 }
コード例 #27
0
 public BookController(UserManager <ApplicationUser> userManager)
 {
     _bookRepo    = new BookRepo();
     _commentRepo = new CommentRepo();
     _userManager = userManager;
 }