public async Task <ServiceResult <CreatedForm> > CreateTopic([FromBody] CreateTopicForm createTopicForm)
        {
            CreatedForm created = new CreatedForm {
            };
            var zone            = await TopicService.ZoneFromId(createTopicForm.ZoneId);

            if (zone.State != ServiceResultEnum.Exist)
            {
                return(Result(zone.State, created, zone.Detail));
            }
            var user = await AccountService.UserFromId(createTopicForm.UserId);

            if (user.State != ServiceResultEnum.Exist)
            {
                return(Result(user.State, created, user.Detail));
            }
            var tags = await TagService.TagsFromStrings(createTopicForm.Tags);

            if (tags.State != ServiceResultEnum.Exist)
            {
                return(Result(tags.State, created, tags.Detail));
            }
            var result = await TopicService.Create(createTopicForm.Title, user.ExtraData, zone.ExtraData, tags.ExtraData, createTopicForm.Content, createTopicForm.Images);

            created.CreatedId = result.ExtraData?.Id;
            return(Result(result.State, created, result.Detail));
        }
Exemplo n.º 2
0
        public OperationResult Create(Topic topic)
        {
            var operationExecution = new OperationExecution();

            Action create = () =>
            {
                var topicService = new TopicService();
                topicService.Create(topic);
            };

            return(operationExecution.ExecuteOperation(create));
        }
Exemplo n.º 3
0
        public IActionResult CreateTopic(TopicCreationViewModel vm)
        {
            if (ModelState.IsValid)
            {
                Member creator = HttpContext.Session.GetMember();

                _topicService.Create(vm.Title, vm.Content, creator.Id);

                return(RedirectToAction(nameof(Index)));
            }

            return(View(vm));
        }
Exemplo n.º 4
0
        public JsonResult Add(TopicModel model)
        {
            long id_gv = long.Parse(Session["UserId"].ToString());

            model.TeacherID = id_gv;
            var tt = practiceService.GetByLoaiTTvaHocKy(model.PracticeID, model.SemesterID);

            model.PracticeTypeID = tt.ID;
            var m = new Topic
            {
                TeacherID      = model.TeacherID,
                PracticeTypeID = model.PracticeTypeID,
                FieldID        = model.FieldID,
                TopicName      = model.TopicName,
                Description    = model.Description,
                Status         = model.Status
            };

            return(Json(topicService.Create(m), JsonRequestBehavior.AllowGet));
        }
        public ActionResult <Topic> Create(Topic topic)
        {
            _topicService.Create(topic);

            return(topic);
        }
Exemplo n.º 6
0
 public ActionResult <Topic> Create([FromBody] Topic topic)
 {
     _topicService.Create(topic);
     return(Ok());
 }