Beispiel #1
0
        public static void Initial(LawyerContext context)
        {
            if (!context.Commentaries.Any())
            {
                Guid parentGuid = Guid.Parse("cfc77d77-4d4c-4514-b632-a80aa7411152");

                List <CommentaryModel> childComments = new List <CommentaryModel>();
                childComments.Add(new CommentaryModel {
                });
                childComments.Add(new CommentaryModel {
                });

                var comment = new CommentaryModel {
                    DocId = 1, UserId = Guid.NewGuid(), Id = parentGuid, Answers = childComments
                };
                context.Commentaries.Add(comment);

                context.SaveChanges();
            }
            if (!context.Bookmarks.Any())
            {
                for (int i = 1; i < 4; i++)
                {
                    var bm = new BookmarkModel
                    {
                        DateAdd = DateTime.Now,
                        DocId   = i,
                    };

                    context.Bookmarks.Add(bm);
                }

                context.SaveChanges();
            }
        }
 public void CreateComment(CommentaryModel commentary)
 {
     if (!String.IsNullOrEmpty(commentary.Comment))
     {
         var dbCommentary = Mapper.Map <Commentary>(commentary);
         UnitOfWork.GetRepository <Commentary>().Insert(dbCommentary);
         UnitOfWork.SaveChanges();
     }
 }
Beispiel #3
0
        public Guid AddComment(CommentaryModel comment)
        {
            comment.Id     = Guid.NewGuid();
            comment.UserId = Guid.NewGuid();

            context.Commentaries.Add(comment);
            context.SaveChanges();

            return(comment.Id);
        }
        public ActionResult CreateCommentary(Guid photoId)
        {
            var comment = new CommentaryModel()
            {
                PhotoId = photoId,
                UserId  = AuthenticationManager.User.Identity.GetUserId()
            };

            return(View(comment));
        }
Beispiel #5
0
        public async Task <IActionResult> Edit(CommentaryModel model)
        {
            Commentary commentary = _database.Commentaries.FirstOrDefault(c => c.Id == model.Id);

            commentary.Text         = model.Text + " [edited]";
            commentary.CreationDate = DateTime.Now;

            await _database.SaveChangesAsync();

            //return RedirectToAction("Details", "BlogArticle", new { id = commentary.BlogArticleId });
            return(Redirect(Url.Action("Details", "BlogArticle", new { id = commentary.BlogArticleId }) + "#commentary-section"));
        }
Beispiel #6
0
        private RequestComment GetChilds(CommentaryModel a)
        {
            var b = new RequestComment
            {
                Id   = a.Id,
                Text = a.Text
            };

            if (a.Answers != null && a.Answers.Any())
            {
                b.Child = a.Answers.Select(x => GetChilds(x)).ToList();
            }

            return(b);
        }
        public async Task <IHttpActionResult> AddCommentary([FromBody] CommentaryModel commentaryModel)
        {
            try
            {
                var commentaryDTO = mapper.Map <CommentaryDTO>(commentaryModel);
                commentaryDTO.User = mapper.Map <UserDTO>(commentaryModel.User);
                await service.AddCommentaryAsync(commentaryDTO);

                return(Ok("Commentary was added succesfully"));
            }
            catch (Exception e)
            {
                return(InternalServerError(e));
            }
        }
Beispiel #8
0
        public ActionResult Post([FromBody] CommentaryModel model)
        {
            comments.AddComment(model);

            return(Ok());
        }
 public ActionResult CreateCommentary(CommentaryModel model)
 {
     ServicesHost.GetService <ICommentaryService>().CreateComment(model);
     return(View());
 }