public async Task SaveAct(ActInfo actModel) { var act = await repository.GetOrInsertAct(actModel.ActGuid); var lastActDescription = act.Descriptions .OrderByDescending(description => description.ModifiedDate) .FirstOrDefault(); if (lastActDescription == null || lastActDescription.Title != actModel.Title || lastActDescription.ImageHash != actModel.ImageHash) { var modifiedTicks = lastActDescription?.ModifiedDate.Ticks ?? 0; if (modifiedTicks != actModel.LastModifiedTicks) { throw new DbUpdateConcurrencyException("A new update has occurred since you loaded the page. Please refresh and try again."); } await repository.AddAsync(new ActDescription { ModifiedDate = DateTime.UtcNow, Act = act, Title = actModel.Title, ImageHash = actModel.ImageHash }); await repository.SaveChangesAsync(); } }
public async Task DeleteVenue(Guid venueGuid) { var venue = await repository.GetOrInsertVenue(venueGuid); await repository.AddAsync(new VenueRemoved { Venue = venue, RemovedDate = DateTime.UtcNow }); await repository.SaveChangesAsync(); }
public async Task CancelShow(Guid actGuid, Guid venueGuid, DateTimeOffset startTime) { var show = await repository.GetOrInsertShow(actGuid, venueGuid, startTime); await repository.AddAsync(new ShowCancelled { Show = show, CancelledDate = DateTime.UtcNow }); await repository.SaveChangesAsync(); }