Esempio n. 1
0
        public void AddComment(AddCommentBm bind)
        {
            Comment   comment    = Mapper.Map <AddCommentBm, Comment>(bind);
            TaskModel wantedTask = this.Context.Tasks.Find(bind.TaskId);

            comment.TaskModel = wantedTask;
            comment.DateAdded = DateTime.Now;
            this.Context.Comments.Add(comment);
            this.Context.SaveChanges();
        }
Esempio n. 2
0
        public ActionResult Add([Bind(Include = "taskId, CommentDescription, CommentType, ReminderDate")] AddCommentBm bind)
        {
            if (this.ModelState.IsValid)
            {
                this.service.AddComment(bind);
                return(this.Redirect("All"));
            }
            var vms = this.service.GetTasks();

            return(View(vms));
        }
Esempio n. 3
0
 public ActionResult Add(AddCommentBm bm, int id)
 {
     try
     {
         this.service.Add(id, bm);
     }
     catch (DbEntityValidationException ex)
     {
         var error = ex.EntityValidationErrors.First().ValidationErrors.First();
         this.ModelState.AddModelError(error.PropertyName, error.ErrorMessage);
     }
     return(this.Redirect("/products/" + id));
 }
Esempio n. 4
0
        public void Add(int id, AddCommentBm bm)
        {
            Comment model = new Comment
            {
                DataAdded = DateTime.Now,
                Author    = bm.Author,
                Content   = bm.Content,
                Product   = this.Context.Products.Find(id)
            };

            this.Context.Comments.Add(model);
            this.Context.SaveChanges();
        }