Beispiel #1
0
 public void DeletePaymentMethod(long id)
 {
     using (var db = new Database(_settings))
     {
         db.Delete<PaymentMethod>("where Id = @0", id);
     }
 }
Beispiel #2
0
 public void CreateEventLog(EventLog eventLog)
 {
     using (var db = new Database(_settings))
     {
         db.Insert(eventLog);
     }
 }
Beispiel #3
0
 public void CreateUser(User user)
 {
     using (var db = new Database(_settings))
     {
         db.Insert(user);
     }
 }
Beispiel #4
0
 public void CreatePaymentMethod(PaymentMethod paymentMethod)
 {
     using (var db = new Database(_settings))
     {
         db.Insert(paymentMethod);
     }
 }
Beispiel #5
0
 public void CreateBankAccount(BankAccount bankAccount)
 {
     using (var db = new Database(_settings))
     {
         db.Insert(bankAccount);
     }
 }
Beispiel #6
0
        public void CreateEvent(Event @event)
        {
            using (var db = new Database(_settings))
            using (var transaction = db.GetTransaction())
            {
                db.Insert(@event.Location);

                @event.LocationId = @event.Location.Id;
                @event.SlotsAvailable = @event.Slots;
                db.Insert(@event);

                foreach (var eventImage in @event.Images)
                {
                    eventImage.EventId = @event.Id;
                    db.Insert(eventImage);
                }

                foreach (var category in @event.Categories)
                {
                    db.Insert(new EventCategory
                    {
                        EventId = @event.Id,
                        CategoryId = category.Id
                    });
                }

                transaction.Complete();
            }
        }
Beispiel #7
0
 public void DeleteBankAccount(long id)
 {
     using (var db = new Database(_settings))
     {
         db.Delete<BankAccount>("where Id = @0", id);
     }
 }
Beispiel #8
0
 public IEnumerable<BankAccount> GetBankAccounts(long userId)
 {
     using (var db = new Database(_settings))
     {
         return db.Query<BankAccount>("where UserId = @0", userId);
     }
 }
Beispiel #9
0
 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();
     }
 }
Beispiel #10
0
 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();
     }
 }
Beispiel #11
0
        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();
            }
        }
Beispiel #12
0
 private IEnumerable<Event> GetEvents(string sql, params object[] parameters)
 {
     using (var db = new Database(_settings))
     {
         var mapper = new EventMapper();
         return db.Query<Event>(mapper.Types, mapper.Map, sql, parameters);
     }
 }
Beispiel #13
0
 public IList<EventRequest> GetEventRequests(int eventId)
 {
     using (var db = new Database(_settings))
     {
         return db.Query<EventRequest>("where EventId = @0", eventId).ToList();
     }
 }
Beispiel #14
0
 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);
     }
 }
Beispiel #15
0
 public IList<Category> GetCategories()
 {
     using (var db = new Database(_settings))
     {
         return db.Query<Category>(string.Empty).ToList();
     }
 }
Beispiel #16
0
 public User GetUser(long id)
 {
     using (var db = new Database(_settings))
     {
         return db.SingleOrDefault<User>("where Id = @0", id);
     }
 }
Beispiel #17
0
 public IEnumerable<PaymentMethod> GetPaymentMethods(long userId)
 {
     using (var db = new Database(_settings))
     {
         return db.Query<PaymentMethod>("where UserId = @0", userId);
     }
 }
Beispiel #18
0
 public void UpdatePaymentMethod(PaymentMethod paymentMethod)
 {
     using (var db = new Database(_settings))
     {
         db.Update<PaymentMethod>("set ExternalId = @1 where Id = @0", paymentMethod.Id, paymentMethod.ExternalId);
     }
 }
Beispiel #19
0
 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);
     }
 }
Beispiel #20
0
 public void SetPaymentId(long userId, string paymentId)
 {
     using (var db = new Database(_settings))
     {
         db.Update<User>("set PaymentId = @1 where Id = @0", userId, paymentId);
     }
 }
Beispiel #21
0
 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);
     }
 }
Beispiel #22
0
 public void CreateEventRequest(EventRequest eventRequest)
 {
     using (var db = new Database(_settings))
     {
         db.Insert(eventRequest);
     }
 }
Beispiel #23
0
 public User GetUserByExternalId(string externalId)
 {
     using (var db = new Database(_settings))
     {
         return db.SingleOrDefault<User>("where ExternalId = @0", externalId);
     }
 }