Exemple #1
0
        public async Task <VenueVm> UpdateVenueAsync(VenueVm venue)
        {
            venue.EnsureIsValid();
            var original = await _venueProvider.GetVenueOrDefaultAsync(venue.Id).ConfigureAwait(false);

            var res = await _venueProvider.SaveVenueAsync(original.Extend(venue)).ConfigureAwait(false);

            return(res.ToVm());
        }
Exemple #2
0
        public async Task <VenueVm> UpdateVenueAsync(VenueVm venue)
        {
            venue.EnsureIsValid();

            var original = await _venueProvider.GetVenueOrDefaultAsync(venue.Id).ConfigureAwait(false);

            original.ExportId = venue.Id;
            original.Name     = venue.Name;
            original.City     = venue.City;
            original.Address  = venue.Address;
            original.MapUrl   = venue.MapUrl;
            await _unitOfWork.SaveChangesAsync();

            return(original.ToVm());
        }
Exemple #3
0
        public async Task <VenueVm> AddVenueAsync(VenueVm venue)
        {
            venue.EnsureIsValid();

            var original = await _venueProvider.GetVenueOrDefaultAsync(venue.Id).ConfigureAwait(false);

            if (original != null)
            {
                throw new FormatException($"Данный {nameof(venue.Id)} \"{venue.Id}\" уже занят");
            }

            var entity = new Venue {
                Id = venue.Id
            }.Extend(venue);
            var res = await _venueProvider.SaveVenueAsync(entity).ConfigureAwait(false);

            return(res.ToVm());
        }