예제 #1
0
        public JsonNetResult Index(FormCollection formCollection)
        {
            Page <Item> page = new Page <Item>();

            page.Params = new Dictionary <string, string>();
            page.Start  = formCollection["start"] == null ? 0 : int.Parse(formCollection["start"]);
            page.Limit  = formCollection["limit"] == null ? 100 : int.Parse(formCollection["limit"]);
            if (!string.IsNullOrEmpty(Request["query"]))
            {
                page.Params.Add("query", formCollection["query"]);
            }
            if (!string.IsNullOrEmpty(Request["brand"]))
            {
                page.Params.Add("brand", formCollection["brand"]);
            }
            int count  = 0;
            var result = dao.FindByPage(page, ref count);

            page.Root          = result;
            page.TotalProperty = count;

            JsonNetResult jsonNetResult = new JsonNetResult();

            jsonNetResult.Formatting = Formatting.Indented;
            jsonNetResult.SerializerSettings.Converters.Add(new JavaScriptDateTimeConverter());
            jsonNetResult.Data = page;

            return(jsonNetResult);
        }