public ActionResult ExportData(RoomFilterModel roomFilterModel) { // Step 1. Obtain your OAuth token string accessToken = RequestItemsService.User.AccessToken; // Represents your {ACCESS_TOKEN} var basePath = $"{RequestItemsService.Session.RoomsApiBasePath}/restapi"; // Base API path // Step 2: Construct your API headers var apiClient = new ApiClient(basePath); apiClient.Configuration.DefaultHeader.Add("Authorization", "Bearer " + accessToken); var roomsApi = new RoomsApi(apiClient); string accountId = RequestItemsService.Session.AccountId; // Represents your {ACCOUNT_ID} try { // Step 3: Prepare your request parameters var fieldDataChangedStartDate = roomFilterModel.FieldDataChangedStartDate.ToString(CultureInfo.InvariantCulture); var fieldDataChangedEndDate = roomFilterModel.FieldDataChangedEndDate.ToString(CultureInfo.InvariantCulture); // Step 4: Call the Rooms API to get rooms with filters RoomSummaryList rooms = roomsApi.GetRooms(accountId, new RoomsApi.GetRoomsOptions { fieldDataChangedStartDate = fieldDataChangedStartDate, fieldDataChangedEndDate = fieldDataChangedEndDate }); ViewBag.h1 = "The rooms with filters was loaded"; ViewBag.message = $"Results from the Rooms: GetRooms method. FieldDataChangedStartDate: " + $"{ roomFilterModel.FieldDataChangedStartDate.Date.ToShortDateString() }, " + $"FieldDataChangedEndDate: { roomFilterModel.FieldDataChangedEndDate.Date.ToShortDateString() } :"; ViewBag.Locals.Json = JsonConvert.SerializeObject(rooms, Formatting.Indented); return(View("example_done")); } catch (ApiException apiException) { ViewBag.errorCode = apiException.ErrorCode; ViewBag.errorMessage = apiException.Message; return(View("Error")); } }
public async Task <IActionResult> Get([FromQuery] RoomFilterModel filter) { //// A non admin user can't filter by hostel that is not owner if (!this.workContext.CurrentUser.IsAdmin() && (!filter.HostelId.HasValue || this.workContext.CurrentUser.HostelId != filter.HostelId.Value)) { return(this.Forbid()); } var rooms = await this.roomService.GetAll( filter.Keyword, filter.HostelId, filter.OnlyPrivated, filter.RoomType, filter.OrderByEnum, null, filter.Page, filter.PageSize); var models = rooms.ToModels(); return(this.Ok(models, rooms.HasNextPage, rooms.TotalCount)); }
public ActionResult ExportData(RoomFilterModel roomFilterModel) { // Obtain your OAuth token string accessToken = RequestItemsService.User.AccessToken; // Represents your {ACCESS_TOKEN} var basePath = $"{RequestItemsService.Session.RoomsApiBasePath}/restapi"; // Base API path string accountId = RequestItemsService.Session.AccountId; // Represents your {ACCOUNT_ID} try { // Prepare your request parameters var fieldDataChangedStartDate = roomFilterModel.FieldDataChangedStartDate.ToString(CultureInfo.InvariantCulture); var fieldDataChangedEndDate = roomFilterModel.FieldDataChangedEndDate.ToString(CultureInfo.InvariantCulture); // Call the Rooms API to get rooms with filters var rooms = GetRoomsWithFilters.GetRooms(basePath, accessToken, accountId, fieldDataChangedStartDate, fieldDataChangedEndDate); ViewBag.h1 = "The rooms with filters was loaded"; ViewBag.message = $"Results from the Rooms: GetRooms method. FieldDataChangedStartDate: " + $"{ roomFilterModel.FieldDataChangedStartDate.Date.ToShortDateString() }, " + $"FieldDataChangedEndDate: { roomFilterModel.FieldDataChangedEndDate.Date.ToShortDateString() } :"; ViewBag.Locals.Json = JsonConvert.SerializeObject(rooms, Formatting.Indented); return(View("example_done")); } catch (ApiException apiException) { ViewBag.errorCode = apiException.ErrorCode; ViewBag.errorMessage = apiException.Message; return(View("Error")); } }
protected override void InitializeInternal() { RoomFilterModel = new RoomFilterModel(); }
public ActionResult Index(RoomFilterModel filter) { var model = _roomIndexBuilder.CreateFrom(filter); return(View(model)); }