示例#1
0
        public async Task <IActionResult> AddReply(long id, string text, long replyid, IFormFile?file)
        {
            string?path = null;

            if (file != null)
            {
                path = "/attachments/" + file.FileName;
                await file.CopyToAsync(new FileStream(_appEnvironment.WebRootPath + path, FileMode.Create));
            }
            long discussid = _discussionService.AddReply(text, HttpContext.User.Identity.Name, id, replyid, path);

            string username = _discussionService.GetDiscussion(replyid).author.username;

            _notificationService.CreateNotification($"User @{HttpContext.User.Identity.Name} added reply to your discuss", username, $"/Room/Detail/{id}");
            return(Redirect($"/Room/Detail/{id}"));
        }
示例#2
0
        public ActionResult Edit(int id)
        {
            Discussion discussion = dService.GetDiscussion(id);

            if (discussion.UserId == _currentUserId || User.IsInRole("Administrator") || User.IsInRole("Moderator") || User.IsInRole("Expert"))
            {
                DiscussionEditViewModel discussionEditVM = new DiscussionEditViewModel();

                discussionEditVM  = Mapper.Map <Discussion, DiscussionEditViewModel>(discussion);
                ViewBag.ReturnUrl = _previousUrl == default(string) ? Url.Action("Detail", new { id = id }) : Url.Content(_previousUrl);
                ViewBag.System    = Constant.String.DiscussionSystem;
                return(View("Views/DiscussionEditView", discussionEditVM));
            }
            //string returnUrl = Request.Cookies.Get("returnUrl") != null ? Request.Cookies.Get("returnUrl").Value : default(string);
            if (_previousUrl == default(string))
            {
                return(RedirectToAction("Detail", new { id = id }));
            }
            else
            {
                return(Redirect(Url.Content(_previousUrl)));
            }
        }
 public IActionResult Get(int id)
 {
     return(Ok(_repo.GetDiscussion(id)));
 }