public async Task UpdatesApartment()
        {
            var request = new UpdateApartmentCommand()
            {
                Id            = this.dbApartment.Id,
                ActivityState = ActivityStates.Inactive,
                ApartmentType = ApartmentTypes.SingleRoom,
                CheckInTime   = "11:00:00",
                CheckOutTime  = "20:15:33",
                Title         = "My new title",
                Latitude      = 33,
                Longitude     = 34,
                CityName      = "New York",
                StreetName    = "Digit Street",
                StreetNumber  = "33",
                CountryName   = "America"
            };

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

            this.dbApartment = await this.Context.Apartments
                               .Include(a => a.Location)
                               .ThenInclude(l => l.Address)
                               .SingleOrDefaultAsync(a => a.Id == request.Id && !a.IsDeleted)
                               .ConfigureAwait(false);

            Assert.NotNull(this.dbApartment);
            Assert.Equal(this.dbApartment.Title, request.Title);
            Assert.NotNull(this.dbApartment.Location);
            Assert.Equal(this.dbApartment.Location.Latitude, request.Latitude);
            Assert.Equal(this.dbApartment.Location.Longitude, request.Longitude);
            Assert.NotNull(this.dbApartment.Location.Address);
            Assert.Equal(this.dbApartment.Location.Address.CountryName, request.CountryName);
        }
示例#2
0
        public async Task <IActionResult> Put(long id, [FromBody] UpdateApartmentCommand command)
        {
            if (await authService.CheckIfBanned(this.User).ConfigureAwait(false))
            {
                return(this.Forbid());
            }

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

            return(this.Ok());
        }
        public async Task <ActionResult> Update([FromBody] UpdateApartmentCommand cmd)
        {
            var result = await mediator.Send(cmd);

            return(new JsonResult(result));
        }