public async Task UpdatesAmenitiesInApartment()
        {
            var reqAmenity = this.Context.Add(new Amenity()
            {
                Name = "Microwave"
            }).Entity;

            var request = new UpdateApartmentAmenitiesCommand()
            {
                ApartmentId = this.dbApartment.Id,
                Amenities   = new List <AmenityDto>()
                {
                    new AmenityDto(reqAmenity)
                }
            };

            await this.sut.Handle(request, CancellationToken.None).ConfigureAwait(false);

            this.dbApartment = await this.Context.Apartments
                               .Include("ApartmentAmenities.Amenity")
                               .SingleOrDefaultAsync(a => a.Id == this.dbApartment.Id, CancellationToken.None).ConfigureAwait(false);

            var dbAmenities = this.dbApartment.ApartmentAmenities
                              .Where(x => !x.IsDeleted)
                              .Select(x => x.Amenity)
                              .Where(a => !a.IsDeleted);

            var dbAmenity = Assert.Single(dbAmenities);

            Assert.Equal(reqAmenity.Name, dbAmenity.Name);
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> UpdateApartmentAmenities(long id, [FromBody] UpdateApartmentAmenitiesCommand command)
        {
            if (await authService.CheckIfBanned(this.User).ConfigureAwait(false))
            {
                return(this.Forbid());
            }

            command.ApartmentId = id;
            await this.mediator.Send(command).ConfigureAwait(false);

            return(this.Ok());
        }