Beispiel #1
0
 public Task Book(Guid performanceId, Guid timeId, int count, Guid userId)
 {
     context.Orders.Add(new Orders
     {
         Count             = count,
         PerformanceTimeId = timeId,
         UserId            = userId
     });
     return(context.SaveChangesAsync());
 }
Beispiel #2
0
        public async Task <int> Book(Guid timeId, int count, Guid userId)
        {
            var order = await context.Orders.FirstOrDefaultAsync(x => x.PerformanceTimeId == timeId && x.UserId == userId).ConfigureAwait(false);

            if (order != null)
            {
                order.Count += count;
                context.Orders.Update(order);
            }
            else
            {
                context.Orders.Add(new Orders
                {
                    Count             = count,
                    PerformanceTimeId = timeId,
                    UserId            = userId
                });
            }
            return(await context.SaveChangesAsync().ConfigureAwait(false));
        }