Beispiel #1
0
        public IActionResult AddReservation([FromBody] M.ReservationCreateUpdateModel reservation)
        {
            var data = _mapper.Map <Reservation>(reservation);

            data.statusId = 1;
            return(Ok(_repository.reservation.Create(data)));
        }
Beispiel #2
0
        public IActionResult UpdateReservation(M.ReservationCreateUpdateModel reservation)
        {
            if (_repository.reservation.FindByCondition(res => res.reservationId == reservation.reservationId) == null)
            {
                return(NotFound());
            }
            var result = _repository.reservation.Update(_mapper.Map <Reservation>(reservation));

            return(Ok(result));
        }
Beispiel #3
0
        public IActionResult AddReservation([FromBody] M.ReservationCreateUpdateModel reservation)
        {
            var disponibility = _repository.Disponibility.FindById(x => x.disponibilityId == reservation.disponibilityId);
            var data          = _mapper.Map <Reservation>(reservation);

            data.professionalId  = disponibility.professionalId;
            data.startHour       = disponibility.startHour;
            data.endHour         = disponibility.EndHour;
            data.reservationDate = data.startHour.Date;

            data.statusId = 1;
            try
            {
                var res = _repository.reservation.Create(data);
                disponibility.reserved = true;
                _repository.Disponibility.Update(disponibility);
                return(new ObjectResult(res));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }