예제 #1
0
        private BookingEntity InsertEntity(BookingSpecialSaveDto bookingSpecialDto)
        {
            BookingEntity entity = Mapper.Map <BookingEntity>(bookingSpecialDto);

            entity.Id     = 0;
            entity.Status = BookingStatusEnum.Special;
            return(entity);
        }
예제 #2
0
        public BookingSpecialDto SaveSpecialBooking(BookingSpecialSaveDto bookingSpecialDto)
        {
            BookingEntity entity = bookingSpecialDto.Id.Value <= 0
                                ? InsertEntity(bookingSpecialDto)
                                : UpdateEntity(bookingSpecialDto);

            _bookingRepository.Save(entity);

            return(Mapper.Map <BookingSpecialDto>(entity));
        }
예제 #3
0
        public BookingSpecialDto PostSpecial([FromBody] BookingSpecialSaveDto bookingSpecialDto)
        {
            Validate();

            if (bookingSpecialDto.From > bookingSpecialDto.To)
            {
                throw new ModelValidationException("From should be less than To");
            }

            return(_bookingManagerService.SaveSpecialBooking(bookingSpecialDto));
        }
예제 #4
0
        private BookingEntity UpdateEntity(BookingSpecialSaveDto bookingSpecialDto)
        {
            BookingEntity entity = _bookingRepository.GetById(bookingSpecialDto.Id.Value);

            ValidateSpecialBooking(entity);

            entity.From = bookingSpecialDto.From.Value;
            entity.To   = bookingSpecialDto.To.Value;
            entity.Code = bookingSpecialDto.Code;

            return(entity);
        }