public void CreateUserRating(UserRating userRating) { using (var db = new Database(_settings)) using (var transaction = db.GetTransaction()) { db.Insert(userRating); var rating = Convert.ToDecimal(db.Query<UserRating>("where UserId = @0", userRating.UserId).Average(r => r.Rating)); db.Update<User>("set Rating = @1 where Id = @0", userRating.UserId, rating); transaction.Complete(); } }
public void CreateUserRating(UserRating userRating) { userRating.Created = DateTime.Now; _userRepository.CreateUserRating(userRating); }