public async Task <IActionResult> Update(int id, [FromBody] ReservationUpdateDTO reservationDTO)
        {
            try
            {
                if (id < 1 || reservationDTO == null || id != reservationDTO.IDReservation)
                {
                    return(BadRequest());
                }

                var isExists = await _reservationRepository.isExists(id);

                if (!isExists)
                {
                    return(NotFound());
                }

                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }
                var reservation = _mapper.Map <Reservation>(reservationDTO);
                var isSuccess   = await _reservationRepository.Update(reservation);

                if (!isSuccess)
                {
                    return(InternalError($"Update failed."));
                }
                return(NoContent());
            }
            catch (Exception e)
            {
                return(InternalError($"{e.Message} - {e.InnerException}"));
            }
        }
Example #2
0
        public async Task <ReservationDTO> PatchAsync(ReservationUpdateDTO reservation)
        {
            this.Logger.LogTrace($"{nameof(this.PutAsync)} called");

            var result = await this.ReservationUpdateService.UpdateAsync(this.Mapper.Map <ReservationUpdateModel>(reservation));

            return(this.Mapper.Map <ReservationDTO>(result));
        }
Example #3
0
        public async Task <ActionResult> Update(int id, ReservationUpdateDTO model)
        {
            if (_ReservationService.Existencia(id) == true)
            {
                await _ReservationService.Update(id, model);

                return(NoContent());
            }
            else
            {
                return(NotFound());
            }
        }
        public async Task Update(int id, ReservationUpdateDTO model)
        {
            var entry = _context.Reservations.Single(x => x.ReservationId == id);

            entry.ReservationId = model.ReservationId;
            entry.Date          = model.Date;
            entry.Discount      = model.Discount;
            entry.Price         = model.Price;
            entry.LocationId    = model.LocationId;
            entry.PaymentId     = model.PaymentId;
            entry.SupplierId    = model.SupplierId;

            await _context.SaveChangesAsync();
        }