public JsonResult GetCategoryByName(string search) { IEnumerable <CategoryModel> _data = new List <CategoryModel>(); try { dt.Clear(); CategoryService catService = new CategoryService(); CommonService commService = new CommonService(); if (string.IsNullOrEmpty(search)) { dt = catService.FindAllCategory(); } else { dt = catService.FindCategoryByName("Str", search); } if (dt.Rows.Count > 0) { _data = commService.ConvertToList <CategoryModel>(dt); } } catch (Exception ex) { } return(Json(_data, JsonRequestBehavior.AllowGet)); }
}//.End SaveBook public ActionResult BookList() { DataTable dt = libraryService.BookList(null); List <BookListModel> bookListModels = CommonService.ConvertToList <BookListModel>(dt); return(View(bookListModels)); }//.BookList
public ActionResult EditBook(int Id) { DataTable dt = libraryService.BookList(Id); List <EditBookModel> _editBookModel = CommonService.ConvertToList <EditBookModel>(dt); EditBookModel editBookModel = _editBookModel.Find(uid => uid.Id == Id); return(View(editBookModel)); }
public JsonResult GetCategoryAll() { // กรณีที่ Datatables กำหนดให้เป็น server side เราต้องกำหนดค่า ต่างๆ เอง // กำหนด จำนวน row // กำหนดค่า ฟิลเตอร์ row // กำหนดค่าค้นหาใน box search ใน datatables // กำหนดค่าให้แสดงกี่แถวต่อหนเา // กำหนดค่า การเรียงลำดับ // กำหนดค่า paging int totalrecord = 0; int filterrecord = 0; IEnumerable <CategoryModel> _data = new List <CategoryModel>(); try { // server side parameter int start = Convert.ToInt32(Request["start"]); int length = Convert.ToInt32(Request["length"]); string searchvalue = Request["search[value]"]; string sortcolunmname = Request["columns[" + Request["order[0][column]"] + "][name]"]; string sortdiraction = Request["order[0][dir]"]; // dt.Clear(); CategoryService catService = new CategoryService(); CommonService commService = new CommonService(); dt = catService.FindCategoryByName("Str", ""); if (dt.Rows.Count > 0) { _data = commService.ConvertToList <CategoryModel>(dt); // กำหนดค่า จำนวน row totalrecord = _data.Count(); // กำหนดให้ช่อง search ใน datatables สามารถค้นหาได้ ตามc colunm ที่กำหนด _data = _data. Where(x => x.CategoryName.ToLower().Contains(searchvalue.ToLower()) || x.Description.ToLower().Contains(searchvalue.ToLower())).ToList <CategoryModel>(); // กำหนดค่า ฟิลเตอร์ row filterrecord = _data.Count(); // กำนหดค่าก่ารเรียงลำดับ (ต้อง Add System.Linq.Dynamic libery เพิ่ม) _data = _data.OrderBy(sortcolunmname + " " + sortdiraction).ToList <CategoryModel>(); // กำหนดค่าของ Paing _data = _data.Skip(start).Take(length).ToList <CategoryModel>(); } } catch (Exception ex) { } return(Json(new { draw = Request["draw"], recordsTotal = totalrecord, recordsFiltered = filterrecord, data = _data }, JsonRequestBehavior.AllowGet)); }
public ActionResult EditCustomer(int id) { if (Session["Email"] != null && Session["UserID"] != null) { ViewBag.ActiveMenu = "AddCustomer"; String userEmail = Session["Email"].ToString(); DataTable dt = _CustomerManagementService.ViewCustomerDetailsList(); List <EditCustomerModel> CustomerList = CommonService.ConvertToList <EditCustomerModel>(dt); EditCustomerModel _EditUserModel = CustomerList.Find(uid => uid.CustomerId == id); DataSet dbInitial = _SystemService.GetInitialDetails(userEmail); _EditUserModel.City = dbInitial.Tables[0].AsEnumerable().Select(row => new CityModel { CityId = Convert.ToInt32(row["CITY_CODE"]), CityName = Convert.ToString(row["CITY_NAME"]) }); _EditUserModel.State = dbInitial.Tables[1].AsEnumerable().Select(row => new StateModel { StateId = Convert.ToInt32(row["STATE_CODE"]), StateName = Convert.ToString(row["STATE_NAME"]) }); _EditUserModel.Country = dbInitial.Tables[2].AsEnumerable().Select(row => new CountryModel { CountryId = Convert.ToInt32(row["COUNTRY_CODE"]), CountryName = Convert.ToString(row["COUNTRY_NAME"]) }); _EditUserModel.Street = dbInitial.Tables[3].AsEnumerable().Select(row => new StreetModel { StreetId = Convert.ToInt32(row["STREET_CODE"]), StreetName = Convert.ToString(row["STREET_NAME"]) }); _EditUserModel.Box = dbInitial.Tables[4].AsEnumerable().Select(row => new BoxModel { BoxId = Convert.ToInt32(row["ID"]), BoxName = Convert.ToString(row["BOX_NAME"]) }); _EditUserModel.Package = dbInitial.Tables[5].AsEnumerable().Select(row => new PackageModel { PackageId = Convert.ToInt32(row["ID"]), PackageName = Convert.ToString(row["PKG_NAME"]) }); return(View(_EditUserModel)); } else { return(RedirectToAction("Login", "Account")); } }//..End of Edit Customer
}//..CreateUser public ActionResult CustomerList() { if (Session["Email"] != null && Session["UserID"] != null) { ViewBag.ActiveMenu = "CustomerList"; DataTable dt = _CustomerManagementService.CustomerList(Session["Email"].ToString()); List <CustomerListModel> CustomerList = CommonService.ConvertToList <CustomerListModel>(dt); return(View(CustomerList)); // redirecting to all Customer List } else { return(RedirectToAction("Login", "Home")); } }//..End CustomerList
}//..CreateUser public ActionResult StreetList() { if (Session["Email"] != null && Session["UserID"] != null) { ViewBag.ActiveMenu = "StreetList"; DataTable dt = _StreetService.StreetList(Session["Email"].ToString()); List <StreetModel> StreetList = CommonService.ConvertToList <StreetModel>(dt); // return View(StreetList); // redirecting to all Street List return(Json(new { data = StreetList }, JsonRequestBehavior.AllowGet)); } else { return(RedirectToAction("Login", "Home")); } }//..End CustomerList
}//..Update User public ActionResult EditStreet(int id) { if (Session["Email"] != null && Session["UserID"] != null) { ViewBag.ActiveMenu = "AddStreet"; String userEmail = Session["Email"].ToString(); DataTable dt = _StreetService.ViewStreetList(); List <EditStreetModel> StreetList = CommonService.ConvertToList <EditStreetModel>(dt); EditStreetModel _EditStreetModel = StreetList.Find(uid => uid.StreetId == id); return(View(_EditStreetModel)); } else { return(RedirectToAction("Login", "Account")); } }//..End of Edit Customer