public Task <CommentMC> New(CommentMC comment, ApplicationUser currentuser)
        {
            var taskResult = Task.Run(() =>
            {
                using (var context = new DbContext())
                {
                    comment.CommentBy = currentuser.Name;

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

                    return(comment);
                }
            });

            return(taskResult);
        }
        public Task Update(CommentMC comment)
        {
            var taskResult = Task.Run(() =>
            {
                using (var context = new DbContext())
                {
                    var cd = context.CommentMCs.FirstOrDefault(c => c.Id == comment.Id);

                    if (cd != null && cd.CreatedBy.Equals(Thread.CurrentPrincipal.Identity.Name))
                    {
                        cd.Text = comment.Text;
                        context.SaveChanges();
                    }
                }
            });

            return(taskResult);
        }
Esempio n. 3
0
 public Task Update(CommentMC comment)
 {
     return(_commentRepository.Update(comment));
 }
Esempio n. 4
0
 public Task <CommentMC> New(CommentMC comment, ApplicationUser currentuser)
 {
     return(_commentRepository.New(comment, currentuser));
 }