Beispiel #1
0
        public async Task <IActionResult> Edit(string id, EditHotelInputModel input)
        {
            if (!this.ModelState.IsValid)
            {
                return(this.View(input));
            }

            await this.hotelService.UpdateAsync(id, input);

            return(this.Redirect("/Hotel/All"));
        }
Beispiel #2
0
        public async Task UpdateAsync(string hotelId, EditHotelInputModel input)
        {
            var hotel = this.hotelsRepository.All()
                        .FirstOrDefault(x => x.Id == hotelId);

            hotel.Name        = input.Name;
            hotel.ImageUrl    = input.ImageUrl;
            hotel.Location    = input.Location;
            hotel.Description = input.Description;

            await this.hotelsRepository.SaveChangesAsync();
        }