public ActionResult AjaxCategoryList(VmJqueryDataTable param) { int totalLength = 0; string searchValue = Request.QueryString["search[value]"]; string columnIndex = Request.QueryString["order[0][column]"]; string orderDirection = Request.QueryString["order[0][dir]"]; var allValues = db.ProductCategory.AsEnumerable(); if (!string.IsNullOrEmpty(searchValue)) { allValues = allValues.Where(w => w.ProductCategoryName.ToLower().Contains(searchValue.ToLower())); } var result = allValues.Select(s => new { ProductCategoryHeaderId = s.ProductCategoryHeaderId, ProductCategoryName = s.ProductCategoryName, ImageUrl = s.ImageUrl }); totalLength = result.Select(s => s.ProductCategoryHeaderId).Count(); if (param.length == -1) { param.length = totalLength; } var displayedValues = result.Skip(param.start) .Take(param.length).ToList(); return(Json(new { sEcho = param.draw, iTotalRecords = result.Count(), iTotalDisplayRecords = totalLength, aaData = displayedValues }, JsonRequestBehavior.AllowGet)); }
public ActionResult AjaxBrandList(VmJqueryDataTable param) { int totalLength = 0; string searchValue = Request.QueryString["search[value]"]; string columnIndex = Request.QueryString["order[0][column]"]; string orderDirection = Request.QueryString["order[0][dir]"]; var allValues = db.FndFlexValueSet.Where(w => w.FlexValueSetShortName == "brand").FirstOrDefault().FndFlexValue.AsEnumerable(); if (!string.IsNullOrEmpty(searchValue)) { allValues = allValues.Where(w => w.FlexValue.ToLower().Contains(searchValue.ToLower())); } var result = allValues.Select(s => new { BrandHeaderId = s.FlexValueId, BrandName = s.FlexValue }); totalLength = result.Select(s => s.BrandHeaderId).Count(); if (param.length == -1) { param.length = totalLength; } var displayedValues = result.Skip(param.start) .Take(param.length).ToList(); return(Json(new { sEcho = param.draw, iTotalRecords = result.Count(), iTotalDisplayRecords = totalLength, aaData = displayedValues }, JsonRequestBehavior.AllowGet)); }
public ActionResult AjaxProductList(VmJqueryDataTable param) { int totalLength = 0; string searchValue = Request.QueryString["search[value]"]; string columnIndex = Request.QueryString["order[0][column]"]; string orderDirection = Request.QueryString["order[0][dir]"]; var flexList = db.FndFlexValue.AsEnumerable(); var allValues = db.Product.ToList(); if (!string.IsNullOrEmpty(searchValue)) { allValues = allValues.Where(w => w.ProductName.ToLower().Contains(searchValue.ToLower()) || w.ProductCode.ToLower().Contains(searchValue.ToLower()) || w.Rate.ToString().ToLower().Contains(searchValue.ToLower()) || (!string.IsNullOrWhiteSpace(w.Description) && w.Description.ToLower().Contains(searchValue.ToLower()))).ToList(); } var result = allValues.Select(s => new VmProductList { ProductHeaderId = s.ProductHeaderId, ProductCategoryName = s.ProductSubCategory.ProductCategory.ProductCategoryName, ProductSubCategoryName = s.ProductSubCategory.ProductSubCategoryName, ProductCode = s.ProductCode, ProductName = s.ProductName, ImageUrl = s.ImageUrl1, BrandName = flexList.FirstOrDefault(f => f.FlexValueId == s.BrandId).FlexValue, UnitName = flexList.FirstOrDefault(f => f.FlexValueId == s.UnitId).FlexValue, Price = s.Rate.ToString("N2"), Description = !string.IsNullOrEmpty(s.Description) && s.Description.Length > 20?s.Description.Substring(0, 20):s.Description, }); totalLength = result.Select(s => s.ProductHeaderId).Count(); if (param.length == -1) { param.length = totalLength; } var displayedValues = result.Skip(param.start) .Take(param.length).ToList(); return(Json(new { sEcho = param.draw, iTotalRecords = result.Count(), iTotalDisplayRecords = totalLength, aaData = result }, JsonRequestBehavior.AllowGet)); }
public ActionResult AjaxOrderList(VmJqueryDataTable param) { var allValues = db.Order.AsEnumerable(); var result = allValues.Select(s => new { s.OrderHeaderId, s.OrderNo, CustomerName = s.Customer.CustomerName ?? "", Mobile = s.Customer.MobileNumber ?? "", Address = s.Customer.Address ?? "", Date = s.OrderDate.ToString("dd MMM yyyy"), Price = s.OrderItem.Select(ss => ss.Total).Any() ? s.OrderItem.Select(ss => ss.Total).Sum() : 0, Items = s.OrderItem.Select(ss => ss.OrderItemHeaderId).Any() ? string.Join(",", s.OrderItem.Select(ss => ss.Product.ProductName)) : "", Status = s.Status == (int)OrderStatus.Pending ? OrderStatus.Pending.ToString() : (s.Status == (int)OrderStatus.Confirmed ? OrderStatus.Confirmed.ToString() : (s.Status == (int)OrderStatus.Delivered ? OrderStatus.Delivered.ToString() : (s.Status == (int)OrderStatus.Completed ? OrderStatus.Completed.ToString() : OrderStatus.Pending.ToString()))), }); return(Json(new { sEcho = param.draw, iTotalRecords = result.Count(), iTotalDisplayRecords = result.Count(), aaData = result }, JsonRequestBehavior.AllowGet)); }