public void CreateEventRating(EventRating eventRating) { using (var db = new Database(_settings)) using (var transaction = db.GetTransaction()) { db.Insert(eventRating); var rating = Convert.ToDecimal(db.Query<EventRating>("where EventId = @0", eventRating.EventId).Average(r => r.Rating)); db.Update<Event>("set Rating = @1 where Id = @0", eventRating.EventId, rating); transaction.Complete(); } }
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 UpdateEventRequest(EventRequest eventRequest) { using (var db = new Database(_settings)) using (var transaction = db.GetTransaction()) { db.Update<EventRequest>("set Status = @2 where EventId = @0 and UserId = @1", eventRequest.EventId, eventRequest.UserId, eventRequest.Status); if (eventRequest.Status == EventRequestStatus.Approved) db.Update<Event>("set SlotsAvailable = SlotsAvailable - 1 where Id = @0", eventRequest.EventId); else if (eventRequest.Status == EventRequestStatus.Cancelled) db.Update<Event>("set SlotsAvailable = SlotsAvailable + 1 where Id = @0", eventRequest.EventId); transaction.Complete(); } }
public void UpdateEvent(Event @event) { using (var db = new Database(_settings)) { db.Update<Event>("set Title = @1, Description = @2, Start = @3, End = @4, Price = @5, Slots = @6 where Id = @0", @event.Id, @event.Title, @event.Description, @event.Start, @event.End, @event.Price, @event.Slots); } }
public void UpdateUser(User user) { using (var db = new Database(_settings)) { db.Update<User>("set Email = @1, Description = @2 where Id = @0", user.Id, user.Email, user.Description); } }
public void UpdatePaymentMethod(PaymentMethod paymentMethod) { using (var db = new Database(_settings)) { db.Update<PaymentMethod>("set ExternalId = @1 where Id = @0", paymentMethod.Id, paymentMethod.ExternalId); } }
public void UpdateBankAccount(BankAccount bankAccount) { using (var db = new Database(_settings)) { db.Update<BankAccount>("set Name = @1, Number = @2 where Id = @0", bankAccount.Id, bankAccount.Name, bankAccount.Number); } }
public void SetPaymentId(long userId, string paymentId) { using (var db = new Database(_settings)) { db.Update<User>("set PaymentId = @1 where Id = @0", userId, paymentId); } }