public static List<BookModel> GetAllBooks(string skip, string top)
        {
            var cache = HttpContext.Current.Cache["allBooks"];
            var model = new BookModel();
            List<BookModel> listAllBooks = new List<BookModel>();

            if (cache == null)
            {
                GetApiResponse<BookModel> apiModelBook= new GetApiResponse<BookModel>();
                listAllBooks = apiModelBook.GetAllBooksFromDb("api/APIDbBook?");
                BookCount = listAllBooks.Count;

                if (top=="0")
                {
                    listAllBooks = apiModelBook.GetAllBooksFromDb("api/APIDbBook?");
                }
                else
                {
                    listAllBooks = apiModelBook.GetAllBooksFromDb("api/APIDbBook?$skip=" + skip + "&$top=" + top );
                }

                cache = listAllBooks;
            }
            else
            {
                listAllBooks = cache as List<BookModel>;
            }
            return listAllBooks;
        }
 public HomeController()
 {
     apiModelBook = new GetApiResponse<BookModel>();
 }
        /// <summary>
        /// Unmarshaller the response from the service to the response class.
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context)
        {
            GetApiResponse response = new GetApiResponse();

            context.Read();
            int targetDepth = context.CurrentDepth;

            while (context.ReadAtDepth(targetDepth))
            {
                if (context.TestExpression("apiEndpoint", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.ApiEndpoint = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("apiId", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.ApiId = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("apiKeySelectionExpression", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.ApiKeySelectionExpression = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("corsConfiguration", targetDepth))
                {
                    var unmarshaller = CorsUnmarshaller.Instance;
                    response.CorsConfiguration = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("createdDate", targetDepth))
                {
                    var unmarshaller = DateTimeUnmarshaller.Instance;
                    response.CreatedDate = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("description", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.Description = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("disableSchemaValidation", targetDepth))
                {
                    var unmarshaller = BoolUnmarshaller.Instance;
                    response.DisableSchemaValidation = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("importInfo", targetDepth))
                {
                    var unmarshaller = new ListUnmarshaller <string, StringUnmarshaller>(StringUnmarshaller.Instance);
                    response.ImportInfo = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("name", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.Name = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("protocolType", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.ProtocolType = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("routeSelectionExpression", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.RouteSelectionExpression = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("tags", targetDepth))
                {
                    var unmarshaller = new DictionaryUnmarshaller <string, string, StringUnmarshaller, StringUnmarshaller>(StringUnmarshaller.Instance, StringUnmarshaller.Instance);
                    response.Tags = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("version", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.Version = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("warnings", targetDepth))
                {
                    var unmarshaller = new ListUnmarshaller <string, StringUnmarshaller>(StringUnmarshaller.Instance);
                    response.Warnings = unmarshaller.Unmarshall(context);
                    continue;
                }
            }

            return(response);
        }
Beispiel #4
0
 public ShoppingCartController()
 {
     apiModelOrder    = new GetApiResponse <OrderModel>();
     apiModelPayment  = new GetApiResponse <PaymentTypeModel>();
     apiModelDelivery = new GetApiResponse <DeliveryTypeModel>();
 }
 public ShoppingCartController()
 {
     apiModelOrder = new GetApiResponse<OrderModel>();
     apiModelPayment = new GetApiResponse<PaymentTypeModel>();
     apiModelDelivery = new GetApiResponse<DeliveryTypeModel>();
 }
Beispiel #6
0
 public HomeController()
 {
     apiModelBook = new GetApiResponse <BookModel>();
 }
 public BookDetailsAndSuggestionsViewModel()
 {
     apiModelBook = new GetApiResponse <BookModel>();
     Suggestions  = new List <BookModel>();
 }
		public AdminController()
		{
			apiModelAdLibris = new GetApiResponse<DisplayAdLibrisForBookModel>();
			apiModelBook = new GetApiResponse<BookModel>();
			apiModelOrder = new GetApiResponse<OrderModel>();
		}
 public BookDetailsAndSuggestionsViewModel()
 {
     apiModelBook = new GetApiResponse<BookModel>();
     Suggestions = new List<BookModel>();
 }
Beispiel #10
0
 public AdminController()
 {
     apiModelAdLibris = new GetApiResponse <DisplayAdLibrisForBookModel>();
     apiModelBook     = new GetApiResponse <BookModel>();
     apiModelOrder    = new GetApiResponse <OrderModel>();
 }