public static int AddOrderRow(OrderRow orderRow) { using (var _context = new EduShopEntities()) { _context.OrderRowSet.AddOrUpdate(orderRow); return(_context.SaveChanges()); } }
public static int AddReview(Review review) { using (var _context = new EduShopEntities()) { _context.ReviewSet.Add(review); return(_context.SaveChanges()); } }
public static int AddUser(User user) { using (var _context = new EduShopEntities()) { user.Password = PasswordHash.CreateHash(user.Password); _context.UserSet.AddOrUpdate(user); return(_context.SaveChanges()); } }
public static int AddOrUpdateProductRating(int id) { using (var _context = new EduShopEntities()) { int rating = ReviewModel.CalculateAverageRating(id); Product product = GetProduct(id); product.AverageRating = rating; _context.ProductSet.AddOrUpdate(product); return(_context.SaveChanges()); } }