コード例 #1
0
        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);
            }
        }
コード例 #2
0
        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 }));
        }
コード例 #3
0
        public async Task <OkObjectResult> SaveBooking(SaveBookingReq request)
        {
            var result = await bookingService.Save(request);

            return(Ok(result));
        }
コード例 #4
0
 public Task <SaveBookingRes> Save(SaveBookingReq request)
 {
     return(bookingRepository.Save(request));
 }