public static int Add(ProductCommentInfo entity) { entity.Id = dal.Add(entity); if (entity.Status == (int)CommentStatus.Show) { ProductBLL.ChangeProductCommentCountAndRank(entity.ProductId, entity.Rank, ChangeAction.Plus); } return(entity.Id); }
public static void Delete(int id) { var comment = Read(id); if (comment.Status == (int)CommentStatus.Show) { ProductBLL.ChangeProductCommentCountAndRank(comment.ProductId, comment.Rank, ChangeAction.Minus); } dal.Delete(id); }
public static void Update(ProductCommentInfo entity, int oldStatus) { dal.Update(entity); if (oldStatus != entity.Status) { if (entity.Status == (int)CommentStatus.Show) { ProductBLL.ChangeProductCommentCountAndRank(entity.ProductId, entity.Rank, ChangeAction.Plus); } else { ProductBLL.ChangeProductCommentCountAndRank(entity.ProductId, entity.Rank, ChangeAction.Minus); } } }
public static void ChangeStatus(int[] ids, int status) { foreach (var id in ids) { var comment = Read(id); if (status == (int)CommentStatus.Show) { if (comment.Status != (int)CommentStatus.Show) { ProductBLL.ChangeProductCommentCountAndRank(comment.ProductId, comment.Rank, ChangeAction.Plus); } } else { if (comment.Status == (int)CommentStatus.Show) { ProductBLL.ChangeProductCommentCountAndRank(comment.ProductId, comment.Rank, ChangeAction.Minus); } } } dal.ChangeStatus(ids, status); }