Esempio n. 1
0
        public async Task <IActionResult> Edit(int id, PublishTopicFormModel model)
        {
            if (!ModelState.IsValid)
            {
                //model.ForEdit = true;
                return(View(model));
            }

            model.Description = this.html.Sanitize(model.Description);

            await this.topics.EditAsync(
                id,
                model.Title,
                model.Description,
                model.CategoryId);

            return(RedirectToAction("Details", "Topics",
                                    new { Area = "", id = id }));
        }
Esempio n. 2
0
        public async Task <IActionResult> Create(PublishTopicFormModel model)
        {
            if (!ModelState.IsValid)
            {
                model.Categories = await this.GetCategories();

                return(View(model));
            }

            model.Description = this.html.Sanitize(model.Description);

            var userId = this.userManager.GetUserId(User);

            var details = await this.topics.CreateAsync(model.Title, model.Description, model.CategoryId, userId);

            if (!details.CategoryIdExist || details.TopicId < 0)
            {
                return(BadRequest());
            }

            return(RedirectToAction("Send", "Emails",
                                    new { Area = "", topicId = details.TopicId, categoryId = model.CategoryId }));
        }