public static void Register(HttpConfiguration config) { // Web API configuration and services // Configure Web API to use only bearer token authentication. config.SuppressDefaultHostAuthentication(); config.Filters.Add(new HostAuthenticationFilter(OAuthDefaults.AuthenticationType)); // Web API routes config.MapHttpAttributeRoutes(); //config.Routes.MapHttpRoute( // name: "DefaultApi", // routeTemplate: "api/{controller}/{id}", // defaults: new { id = RouteParameter.Optional } //); //resolve CORS issue : i.e. response for preflight has invalid http status code 405 web api if (AppConfigReaderHelper.AppConfigToBool(AppSettingKeys.CorsEnabled)) { var cors = new EnableCorsAttribute("*", "*", "*", "*"); config.EnableCors(cors); } config.Services.Replace(typeof(IExceptionLogger), new GlobalExceptionLogger()); config.Services.Replace(typeof(IExceptionHandler), new GlobalExceptionHandler()); }
public GetPaymentChargesResponseDto GetPaymentCharges([FromBody] GetInvoiceRequestDto request) { if (request == null || request.PropertyId <= 0 || request.RoomTypeId <= 0 || request.RoomId <= 0 ) { throw new PmsException("Get Invoice call failed."); } var response = new GetPaymentChargesResponseDto(); if (!AppConfigReaderHelper.AppConfigToBool(AppSettingKeys.MockEnabled)) { response.Tax = _iPmsLogic.GetPaymentCharges(request); return(response); } //mock data response.Tax = new List <Resources.Entities.Tax> { new Tax { TaxName = "ROOM CHARGES", Id = 4, Value = 11, IsDefaultCharges = true }, new Tax { TaxName = "VAT", Id = 1, Value = 10, IsDefaultCharges = true }, new Tax { TaxName = "ServiceTax", Id = 2, Value = 20, IsDefaultCharges = true }, new Tax { TaxName = "Misc Tax", Id = 3, Value = 30, IsDefaultCharges = false } }; return(response); }
public GetPropertyResponseDto GetAllProperty(int userId = 0) { var response = new GetPropertyResponseDto(); if (!AppConfigReaderHelper.AppConfigToBool(AppSettingKeys.MockEnabled)) { return(GetPropertyByUserId(userId)); } else { //mock data } return(response); }
public GetRoomStatusResponseDto GetRoomStatus() { var response = new GetRoomStatusResponseDto(); if (!AppConfigReaderHelper.AppConfigToBool(AppSettingKeys.MockEnabled)) { response.RoomStatuses = _iPmsLogic.GetRoomStatus(); } else { //mock data } return(response); }
public GetRewardCategoryResponseDto GetAllRewardCategory() { var response = new GetRewardCategoryResponseDto(); if (!AppConfigReaderHelper.AppConfigToBool(AppSettingKeys.MockEnabled)) { response.RewardCategories = _iPmsLogic.GetAllRewardCategory(); } else { //mock data } return(response); }
public GetPropertyTypeResponseDto GetAllPropertyType() { var response = new GetPropertyTypeResponseDto(); if (!AppConfigReaderHelper.AppConfigToBool(AppSettingKeys.MockEnabled)) { response.PropertyTypes = _iPmsLogic.GetAllPropertyType(); } else { //mock data } return(response); }
public GetRoomRateResponseDto GetRoomRateByProperty(int propertyId) { if (propertyId <= 0) { throw new PmsException("Property id is not valid."); } var response = new GetRoomRateResponseDto(); if (!AppConfigReaderHelper.AppConfigToBool(AppSettingKeys.MockEnabled)) { response.RoomRate = _iPmsLogic.GetRoomRateByProperty(propertyId); } return(response); }
public GetRateTypeResponseDto GetRateTypeByProperty(int propertyId) { if (propertyId <= 0) { throw new PmsException("Property id is not valid."); } var response = new GetRateTypeResponseDto(); if (!AppConfigReaderHelper.AppConfigToBool(AppSettingKeys.MockEnabled)) { response.RateTypes = _iPmsLogic.GetRateTypeByProperty(propertyId); } else { //mock data response.RateTypes = new List <Resources.Entities.RateType> { new PmsEntity.RateType { Id = 1, Name = "Apartment Standard Test" }, new PmsEntity.RateType { Id = 2, Name = "Apartment Standard" }, new PmsEntity.RateType { Id = 3, Name = "Queen Standard" }, new PmsEntity.RateType { Id = 4, Name = "Holiday Standard" }, new PmsEntity.RateType { Id = 5, Name = "My Weekend Standard" } }; } return(response); }
public GetRewardResponseDto GetRewardByGuestId(int guestId) { if (guestId <= 0) { throw new PmsException("Invalid Guest Id."); } var response = new GetRewardResponseDto(); if (!AppConfigReaderHelper.AppConfigToBool(AppSettingKeys.MockEnabled)) { response.Rewards = _iPmsLogic.GetRewardByGuestId(guestId); } else { //mock data } return(response); }
public GetRoomTypeResponseDto GetRoomTypeByProperty(int propertyId) { if (propertyId <= 0) { throw new PmsException("Property id is not valid."); } var response = new GetRoomTypeResponseDto(); if (!AppConfigReaderHelper.AppConfigToBool(AppSettingKeys.MockEnabled)) { response.RoomTypes = _iPmsLogic.GetRoomTypeByProperty(propertyId); } else { //mock data response.RoomTypes = new List <Resources.Entities.RoomType> { new PmsEntity.RoomType { Id = 1, Name = "King-Smoking", }, new PmsEntity.RoomType { Id = 2, Name = "King-NonSmoking" }, new PmsEntity.RoomType { Id = 3, Name = "Queen-Smoking" }, new PmsEntity.RoomType { Id = 4, Name = "Test King-Smoking" } }; } return(response); }
public GetBookingResponseDto GetBookingById(int bookingId) { if (bookingId <= 0) { throw new PmsException("Get Booking call failed."); } var response = new GetBookingResponseDto(); if (!AppConfigReaderHelper.AppConfigToBool(AppSettingKeys.MockEnabled)) { var booking = _iPmsLogic.GetBookingById(bookingId); response.Bookings = new List <Booking>(); response.Bookings.Add(booking); } else { //mock data response.Bookings = new List <Resources.Entities.Booking> { new Booking { CheckinTime = Convert.ToDateTime(String.Format("{0:s}", DateTime.Now)), CheckoutTime = Convert.ToDateTime(String.Format("{0:s}", DateTime.Now.AddHours(3))), RoomBookings = new List <RoomBooking> { new RoomBooking { Id = 100, Room = new Room { Id = 1, Number = "Room B" }, Guest = new Guest { Id = 11, FirstName = "Tyagi", LastName = "Sachin" } }, new RoomBooking { Id = 200, Room = new Room { Id = 2, Number = "Room C" }, Guest = new Guest { Id = 22, FirstName = "Sharma", LastName = "Sachin" } }, new RoomBooking { Id = 300, Room = new Room { Id = 3, Number = "Room D" }, Guest = new Guest { Id = 33, FirstName = "Deepak", LastName = "Sachin" } }, new RoomBooking { Id = 400, Room = new Room { Id = 4, Number = "Room E" }, Guest = new Guest { Id = 44, FirstName = "Sharma123", LastName = "Sachin" } } } } }; } return(response); }
public GetBookingResponseDto GetBooking(int propertyId) { if (propertyId <= 0) { throw new PmsException("Get Booking call failed."); } var queryParams = Request.GetQueryNameValuePairs(); var startDate = queryParams.FirstOrDefault(x => x.Key == "startdate").Value; var endDate = queryParams.FirstOrDefault(x => x.Key == "enddate").Value; var dtFormats = new[] { "dd/MM/yyyy", "yyyy-MM-dd", "dd/M/yyyy", "dd/MM/yyyy" }; DateTime dtStart; DateTime dtEnd; if (startDate == null || !DateTime.TryParseExact(startDate, dtFormats, CultureInfo.InvariantCulture, DateTimeStyles.None, out dtStart)) { throw new PmsException("Incorrect booking start date"); } if (endDate == null || !DateTime.TryParseExact(endDate, dtFormats, CultureInfo.InvariantCulture, DateTimeStyles.None, out dtEnd)) { throw new PmsException("Incorrect booking end date"); } var response = new GetBookingResponseDto(); if (!AppConfigReaderHelper.AppConfigToBool(AppSettingKeys.MockEnabled)) { response.Bookings = _iPmsLogic.GetBooking(propertyId, dtStart, dtEnd); } else { //mock data response.Bookings = new List <Resources.Entities.Booking> { new Booking { CheckinTime = Convert.ToDateTime(String.Format("{0:s}", DateTime.Now)), CheckoutTime = Convert.ToDateTime(String.Format("{0:s}", DateTime.Now.AddHours(3))), RoomBookings = new List <RoomBooking> { new RoomBooking { Id = 100, Room = new Room { Id = 1, Number = "Room B" }, Guest = new Guest { Id = 11, FirstName = "Tyagi", LastName = "Sachin" } }, new RoomBooking { Id = 200, Room = new Room { Id = 2, Number = "Room C" }, Guest = new Guest { Id = 22, FirstName = "Sharma", LastName = "Sachin" } }, new RoomBooking { Id = 300, Room = new Room { Id = 3, Number = "Room D" }, Guest = new Guest { Id = 33, FirstName = "Deepak", LastName = "Sachin" } }, new RoomBooking { Id = 400, Room = new Room { Id = 4, Number = "Room E" }, Guest = new Guest { Id = 44, FirstName = "Sharma123", LastName = "Sachin" } } } } }; } return(response); }