Example #1
0
        public async Task <IActionResult> CreateTopic(CreateTopicViewModel vm)
        {
            User user = await _userManager.GetUserAsync(HttpContext.User);

            Topic topic = new Topic()
            {
                Title       = vm.Title,
                Description = vm.Description,
                Forum       = await _forumRepository.GetById(vm.Forum.Id),
                Posts       = new List <Post>
                {
                    new Post {
                        Contents = vm.Contents,
                        User     = user,
                        Created  = DateTime.Now,
                        Updated  = DateTime.Now
                    }
                },
                User    = user,
                Created = DateTime.Now,
                Updated = DateTime.Now
            };

            int topic_id = await _topicRepository.Create(topic);

            await _userRepository.CountPost(user.Id);

            return(RedirectToAction("Topic", new { id = topic_id }));
        }
Example #2
0
        public async Task <ActionResult> Publish(Topic topic)
        {
            topic.Creator  = AuthController.LoggedInUser;
            topic.FilePath = "/";
            _topicRepository.Create(topic);
            await StorageApi.PostTopicBody(topic);

            Cache[topic.Name] = topic;
            return(RedirectToAction(topic.Name, "Topics"));
        }
Example #3
0
        public RedirectToRouteResult Create(string topicName)
        {
            TopicModel topic = new TopicModel {
                TopicName = topicName
            };

            _topicRepository.Create(topic);
            _topicRepository.Save();

            return(RedirectToAction("Index", "Home"));
        }
Example #4
0
        public void TestEntityCreate()
        {
            var topic = new Topic("Nome teste");

            var mockTeste = new Mock <ICreateDB <Topic> >();

            var topicRepository = new TopicRepository(mockTeste.Object);

            topicRepository.Create(topic);

            mockTeste.Verify(x => x.CreateNewRegister(It.IsAny <Topic>()));
        }
        public ActionResult Create([Bind(Include = "ID,Subject,Created,UsersID,StatusID")] Topic topic)
        {
            if (ModelState.IsValid)
            {
                repTopic.Create(topic);

                return(RedirectToAction("Index"));
            }

            ViewBag.StatusID = new SelectList(repTopic.Read(), "Id", "Name", topic.StatusID);
            ViewBag.UsersID  = new SelectList(repTopic.Read(), "Id", "UserName", topic.UserID);
            return(View(topic));
        }