Ejemplo n.º 1
0
 public ActionResult Index(int?id)
 {
     if (id == null)
     {
         return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
     }
     else
     {
         var model = _sanphamService.GetAll().Where(x => x.maloai == id).ToList();
         IEnumerable <SanphamViewModel> sp;
         sp = model;
         return(View(model));
     }
 }
Ejemplo n.º 2
0
        public JsonResult GetAllTin(string keyword, int page, int pageSize)
        {
            try
            {
                var data = _sanphamService.GetAll();
                if (!string.IsNullOrEmpty(keyword))
                {
                    var keysearch = keyword.Trim().ToUpper();

                    data = data.Where(x => x.NccNavigation.tenncc.ToUpper().Contains(keysearch)).ToList();
                }
                int totalRow = data.Count();
                data = data.OrderByDescending(x => x.KeyId).Skip((page - 1) * pageSize).Take(pageSize).ToList();
                //JsonSerializerSettings jss = new JsonSerializerSettings { ReferenceLoopHandling = ReferenceLoopHandling.Ignore };
                //var result = JsonConvert.SerializeObject(data, Formatting.Indented, jss);
                return(Json(new { Result = data, PageCount = totalRow, Status = "OK" }, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                Response.StatusCode = (int)HttpStatusCode.BadRequest;
                return(Json(new { Result = ex.Message, Status = "FAIL" }, JsonRequestBehavior.AllowGet));
            }
        }