public async Task <SaveBookingRes> Save(SaveBookingReq saveBookingReq) { SaveBookingRes Result = new SaveBookingRes(); try { DynamicParameters parameters = new DynamicParameters(); parameters.Add("@Id", saveBookingReq.Id); parameters.Add("@CustomerId", saveBookingReq.CustomerId); parameters.Add("@AmountNight", saveBookingReq.AmountNight); parameters.Add("@CheckIn", saveBookingReq.Checkin); parameters.Add("@CheckOut", saveBookingReq.CheckOut); parameters.Add("@Status", saveBookingReq.Status); Result = await SqlMapper.QueryFirstOrDefaultAsync <SaveBookingRes>(cnn : connection, sql : "sp_SaveBooking", param : parameters, commandType : CommandType.StoredProcedure); return(Result); } catch (Exception) { return(Result); } }
public JsonResult Save([FromBody] SaveBookingReq request) { //Tính số đêm bằng cách lấy ngày checkout trừ ngày checkin request.AmountNight = (int)request.CheckOut.Subtract(request.CheckIn).TotalDays; var result = ApiHelper <ResResult> .HttpPostAsync($"booking/save", "POST", request); return(Json(new { data = result })); }
public async Task <OkObjectResult> SaveBooking(SaveBookingReq request) { var result = await bookingService.Save(request); return(Ok(result)); }
public Task <SaveBookingRes> Save(SaveBookingReq request) { return(bookingRepository.Save(request)); }