private BookingEntity InsertEntity(BookingSpecialSaveDto bookingSpecialDto) { BookingEntity entity = Mapper.Map <BookingEntity>(bookingSpecialDto); entity.Id = 0; entity.Status = BookingStatusEnum.Special; return(entity); }
public BookingSpecialDto SaveSpecialBooking(BookingSpecialSaveDto bookingSpecialDto) { BookingEntity entity = bookingSpecialDto.Id.Value <= 0 ? InsertEntity(bookingSpecialDto) : UpdateEntity(bookingSpecialDto); _bookingRepository.Save(entity); return(Mapper.Map <BookingSpecialDto>(entity)); }
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)); }
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); }