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()); }
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)); }