public static bool Delete(Core.Models.Comment entity) { try { using (var ctx = new Data.AmstramgramContext()) { var commentRepo = new Data.Repositories.CommentRepository(ctx, null); commentRepo.Delete(entity); return(commentRepo.SaveChanges()); } } catch { return(false); } }
public ActionResult Create(Comment comment) { comment.MakeDate = DateTime.Now; if (ModelState.IsValid) { rComment.Create(comment); } var comments = (from p in rComment.GetList(p => p.OrderId == comment.OrderId).ToList() select new CommentView() { Id = p.Id, MakeDate = p.MakeDate, Content = p.Content }); return PartialView("Index", comments.ToList()); }
public static Core.Models.Comment Add(Core.Models.Comment entity) { try { using (var ctx = new Data.AmstramgramContext()) { var commentRepo = new Data.Repositories.CommentRepository(ctx, null); var result = commentRepo.Add(entity); if (!commentRepo.SaveChanges()) { return(null); } return(result); } } catch { return(null); } }