public async Task CancelBooking_TicketBookedshouldbecancelled() { //Arrange string userid = "222", userName = "******"; string BookingID = "354436"; BookingCancel objBookingCancel = new BookingCancel(); objBookingCancel.BookingID = BookingID; objBookingCancel.UserID = userid; objBookingCancel.UserName = userName; BookingCancelResponse objBookingCancelResponse = new BookingCancelResponse(); objBookingCancelResponse.ResponseMessage = "Booking Cancelled"; objBookingCancelResponse.UserID = userid; objBookingCancelResponse.UserName = userName; objBookingCancelResponse.BookingID = BookingID; _eventBookingService.Setup(x => x.CancelBooking(objBookingCancel)).ReturnsAsync(objBookingCancelResponse); //Act var customer = await _EventBookingController.CancelBooking(objBookingCancel); //Assert Assert.NotNull(customer); }
public async Task CancelBooking_TicketBookedshouldbecancelled() { //Arrange string userid = "222", userName = "******"; string BookingID = "354436"; BookingCancel objBookingCancel = new BookingCancel(); objBookingCancel.BookingID = BookingID; objBookingCancel.UserID = userid; objBookingCancel.UserName = userName; _eventRepoMock.Setup(x => x.CancelBookingDB(objBookingCancel)).ReturnsAsync("Booking Cancelled"); BookingCancelResponse objBookingCancelResponse = new BookingCancelResponse(); objBookingCancelResponse.ResponseMessage = "Booking Cancelled"; objBookingCancelResponse.UserID = userid; objBookingCancelResponse.UserName = userName; objBookingCancelResponse.BookingID = BookingID; //Act var customer = await _EventBookingService.CancelBooking(objBookingCancel); //Assert Assert.Equal(objBookingCancelResponse.ResponseMessage, customer.ResponseMessage); Assert.Equal(objBookingCancelResponse.UserID, customer.UserID); Assert.Equal(objBookingCancelResponse.UserName, customer.UserName); Assert.Equal(objBookingCancelResponse.BookingID, customer.BookingID); }
public async Task CancelBooking_TicketBookedshouldbecancelled() { //Arrange string userid = "222", userName = "******"; string BookingID = "354436"; BookingCancel objBookingCancel = new BookingCancel(); objBookingCancel.BookingID = BookingID; objBookingCancel.UserID = userid; objBookingCancel.UserName = userName; string queryString = ""; queryString = "sp_CustBookingCancel @userID,@userName,@BookingID,@MessageStatus OUT"; _eventDBMock.Setup(x => x.ExecuteAsyncSql(It.IsAny <SqlParameter[]>(), queryString, 3)).ReturnsAsync("Booking Cancelled"); BookingCancelResponse objBookingCancelResponse = new BookingCancelResponse(); objBookingCancelResponse.ResponseMessage = "Booking Cancelled"; objBookingCancelResponse.UserID = userid; objBookingCancelResponse.UserName = userName; objBookingCancelResponse.BookingID = BookingID; //Act var customer = await _eventBookingRepository.CancelBookingDB(objBookingCancel); //Assert Assert.Equal(objBookingCancelResponse.ResponseMessage, customer); }
public async Task <ActionResult> Delete([FromBody] BookingCancel bookingCancel) { try { await _bookingService.CancelBooking(bookingCancel); string message = $"Endpoint cancelReservation: The booking {bookingCancel.BookingId} was removed."; _logger.LogInformation(message); return(StatusCode(StatusCodes.Status200OK, new { Message = message })); } catch (BookingException ex) { var statusCode = ex.Code switch { BookingExceptionCode.Unknown => StatusCodes.Status500InternalServerError, BookingExceptionCode.Unauthorized => StatusCodes.Status401Unauthorized, BookingExceptionCode.NotFound => StatusCodes.Status404NotFound, _ => StatusCodes.Status500InternalServerError, }; _logger.LogError($"Endpoint cancelReservation: {ex.Code} {ex.Message}"); return(StatusCode(statusCode, new { ex.Message })); } catch (Exception ex) { _logger.LogCritical($"Endpoint cancelReservation: {ex.Message}"); return(StatusCode(StatusCodes.Status500InternalServerError, new { Error = ex.Message })); } }
public async Task <string> CancelBookingDB(BookingCancel ObjBookingCancel) { string ResponseMessage = ""; try { var param = new SqlParameter[] { new SqlParameter() { ParameterName = "@userID", SqlDbType = System.Data.SqlDbType.VarChar, Size = 10, Direction = System.Data.ParameterDirection.Input, Value = string.IsNullOrEmpty(ObjBookingCancel.UserID)?String.Empty:ObjBookingCancel.UserID }, new SqlParameter() { ParameterName = "@userName", SqlDbType = System.Data.SqlDbType.VarChar, Size = 100, Direction = System.Data.ParameterDirection.Input, Value = string.IsNullOrEmpty(ObjBookingCancel.UserName)?String.Empty:ObjBookingCancel.UserName }, new SqlParameter() { ParameterName = "@BookingID", SqlDbType = System.Data.SqlDbType.VarChar, Size = 30, Direction = System.Data.ParameterDirection.Input, Value = string.IsNullOrEmpty(ObjBookingCancel.BookingID)?String.Empty:ObjBookingCancel.BookingID }, new SqlParameter() { ParameterName = "@MessageStatus", SqlDbType = System.Data.SqlDbType.VarChar, Size = -1, Direction = System.Data.ParameterDirection.Output } }; string queryString = ""; queryString = "sp_CustBookingCancel @userID,@userName,@BookingID,@MessageStatus OUT"; ResponseMessage = await _IDBLayercs.ExecuteAsyncSql(param, queryString, 3); //var _Context = new AuthenticationContext(); //int affectedRows = await _Context.Database.ExecuteSqlRawAsync("sp_CustBookingCancel @userID,@userName,@BookingID,@MessageStatus OUT", param); //ResponseMessage = Convert.ToString(param[3].Value); } catch (Exception ex) { ResponseMessage = ex.Message.ToString(); } return(ResponseMessage); }
public async Task <BookingCancelResponse> CancelBooking(BookingCancel ObjBookingCancel) { BookingCancelResponse objBookingCancelResponse = new BookingCancelResponse(); string ResponseMessage = await _eventBookingRepository.CancelBookingDB(ObjBookingCancel); objBookingCancelResponse.ResponseMessage = ResponseMessage; objBookingCancelResponse.UserID = ObjBookingCancel.UserID; objBookingCancelResponse.UserName = ObjBookingCancel.UserName; objBookingCancelResponse.BookingID = ObjBookingCancel.BookingID; return(objBookingCancelResponse); }
public async Task <IActionResult> CancelBooking(BookingCancel ObjBookingCancel) { var bookEntities = await _eventBookingService.CancelBooking(ObjBookingCancel); return(Ok(bookEntities)); }