public JsonResult Get() { if (Session["user"] == null) { return Json(new { success = false }, JsonRequestBehavior.AllowGet); } CustomerModel selfModel = new CustomerModel(); List<Client> _res = new List<Client>(); RoleModel roleModel = new RoleModel(); Role adminRole = roleModel.findByName("Administrator"); Role sellerRole = roleModel.findByName("Seller"); User user = (User) Session["user"]; if (user.Role.RoleId.Equals(adminRole.RoleId)) { _res = selfModel.findAll().ToList(); } else if (user.Role.RoleId.Equals(sellerRole.RoleId)) { _res = selfModel.findBySellerId(user.UserId).ToList(); } return Json(new { success = true, rowData = _res }, JsonRequestBehavior.AllowGet); }
// // GET: /Seller/ public JsonResult Get() { var roleModel = new RoleModel(); Role sellerRole = roleModel.findByName("Seller"); var sellerList = sellerRole.User.ToList(); var _res = from U in sellerList select new SellerViewModel { Name = U.Name , UserId = U.UserId }; return Json(new { success = true, rowData = _res }, JsonRequestBehavior.AllowGet); }