public ActionResult <BookingAdapterOut> Post([FromBody] BookingAdapterIn value) { try { BookingOrder booking = _bookingService.Create(new BookingOrder { Id = value.Id, Product = _productService.Read(value.Product.Id), User = _UserInfoservice.Read(value.User.Id), StartTimeOfBooking = DateConverter.FromUTCEpochToDatetime(value.StartTimeOfBooking), EndTimeOfBooking = DateConverter.FromUTCEpochToDatetime(value.EndTimeOfBooking) }); return(Created("" + booking.Id, new BookingAdapterOut { Id = booking.Id, Product = booking.Product, User = booking.User, StartTimeOfBooking = DateConverter.FromDatetimeToUTCEpoch(booking.StartTimeOfBooking), EndTimeOfBooking = DateConverter.FromDatetimeToUTCEpoch(booking.EndTimeOfBooking) })); } catch (Exception e) { return(BadRequest(e.Message)); } }
public ActionResult Put([FromBody] BookingAdapterIn value) { try { _bookingService.Update(new BookingOrder { Id = value.Id, Product = _productService.Read(value.Product.Id), User = _UserInfoservice.Read(value.User.Id), StartTimeOfBooking = DateConverter.FromUTCEpochToDatetime(value.StartTimeOfBooking), EndTimeOfBooking = DateConverter.FromUTCEpochToDatetime(value.EndTimeOfBooking) }); return(NoContent()); } catch (Exception e) { return(BadRequest(e.Message)); } }