Ejemplo n.º 1
0
        private async Task <int> InvokeTransaction(ArticleCommentViewModel model, string strUrl)
        {
            var result =
                await APIProvider.Authorize_DynamicTransaction <ArticleCommentViewModel, int>(model, _userSession.BearerToken, strUrl, APIConstant.API_Resource_CORE, ARS.IgnoredARS);

            return(result);
        }
Ejemplo n.º 2
0
        public async Task <int> Transaction(ArticleCommentViewModel model, char action)
        {
            //model.PatientId = 1;
            var data = Mapper.Map <ArticleCommentEdit>(model);

            return(await _articleCommentRepo.Transaction(data, action));
        }
Ejemplo n.º 3
0
        public IActionResult Create(int id)
        {
            ArticleCommentViewModel model = new ArticleCommentViewModel();

            model.id = id;
            return(View(model));
        }
Ejemplo n.º 4
0
        private async Task <ArticlesModel> SetArticleComment(ArticleCommentViewModel comment)
        {
            ArticlesModel articlecomment = new ArticlesModel();
            var           article        = await GetArticle(comment.ArticleId);

            var comments = await GetComments(comment.ArticleId);

            articlecomment.ArticleViewModel       = article;
            articlecomment.lstArticleCommentModel = comments;

            articlecomment.ArticleCommentModel = comment;

            return(articlecomment);
        }
Ejemplo n.º 5
0
        public ActionResult LoadComment()
        {
            int id          = int.Parse(Request["id"]);
            var CommentList = ArticelCommentBLL.LoadEntity(a => a.ArticelID == id && a.IsPass == 1).ToList();
            List <ArticleCommentViewModel> newList = new List <ArticleCommentViewModel>();

            foreach (var articleModel in CommentList)
            {
                ArticleCommentViewModel model = new ArticleCommentViewModel();
                TimeSpan ts = DateTime.Now - articleModel.AddDate;
                model.AddDate = WebCommon.GetTimespan(ts);
                model.Msg     = articleModel.Msg;
                newList.Add(model);
            }
            return(Content(Common.SerializeHelper.SerializeToString(newList)));
        }
Ejemplo n.º 6
0
 public RedirectToRouteResult CommentCreate(ArticleCommentViewModel model)
 {
     ArticleComment comment = new ArticleComment();
     comment.Author = Membership.GetUser().UserName;
     comment.Date = DateTime.Now;
     comment.Text = model.Text;
     if (ModelState.IsValid)
     {
         var article = db.Articles.Find(model.ArticleID);
         article.ArticleComments.Add(comment);
         db.SaveChanges();
     }
     else
     {
         ViewBag.CommentError = "Błąd! Komentarza nie dodano.";
     }
     return RedirectToAction("Details", new { ID = model.ArticleID });
 }
Ejemplo n.º 7
0
        public async Task <ArticleCommentViewModel> Post(ArticleCommentViewModel model)
        {
            if (ModelState.IsValid)
            {
                var domainEntity = Mapper.Map <ArticleComment>(model);

                _dbContext.ArticleComments.Add(domainEntity);

                await _dbContext.SaveChangesAsync();

                model = Mapper.Map <ArticleCommentViewModel>(domainEntity);

                return(model);
            }
            else
            {
                throw new System.Exception("Bad request");
            }
        }
        public async Task <JsonResult> SubmitComment(ArticleCommentViewModel viewModel)
        {
            CaptchaResponse captchaResult = await _mediator.Send(new ValidateCaptchaQuery());

            if (captchaResult.Success != "true")
            {
                return(Json(new { status = "FailedTheCaptchaValidation" }));
            }

            if (!ModelState.IsValid)
            {
                return(Json(new { Status = "CannotHaveEmptyArgument" }));
            }

            var articleComment = _mapper.Map <ArticleCommentViewModel, ArticleComment>(viewModel);

            await _mediator.Send(new AddCommentToArticleCommand { ArticleComment = articleComment });

            return(Json(new { Status = "Success" }));
        }