Ejemplo n.º 1
0
        public void GetAllTest()
        {
            var target = new RoleDao();
            ReadOnlyCollection <Role> actual;

            actual = target.GetAll();
            Assert.AreEqual(2, actual.Count);
        }
Ejemplo n.º 2
0
        public JsonResult GetRoles(string sord, int page, int rows, string searchString)
        {
            //#1 Create Instance of DatabaseContext class for Accessing Database.

            //#2 Setting Paging
            int pageIndex = Convert.ToInt32(page) - 1;
            int pageSize  = rows;
            var db        = new RoleDao();
            //#3 Linq Query to Get Customer
            var Results = db.GetAll();

            //#4 Get Total Row Count
            int totalRecords = Results.Count();
            var totalPages   = (int)Math.Ceiling((float)totalRecords / (float)rows);

            //#5 Setting Sorting
            if (sord.ToUpper() == "DESC")
            {
                Results = Results.OrderByDescending(s => s.ID);
                Results = Results.Skip(pageIndex * pageSize).Take(pageSize);
            }
            else
            {
                Results = Results.OrderBy(s => s.ID);
                Results = Results.Skip(pageIndex * pageSize).Take(pageSize);
            }
            //#6 Setting Search
            if (!string.IsNullOrEmpty(searchString))
            {
                Results = Results.Where(m => m.Name.Contains(searchString)).ToList();
            }
            //#7 Sending Json Object to View.
            var jsonData = new
            {
                total = totalPages,
                page,
                records = totalRecords,
                rows    = Results
            };

            return(Json(jsonData, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 3
0
 public void GetAllTest()
 {
     var target = new RoleDao();
     ReadOnlyCollection<Role> actual;
     actual = target.GetAll();
     Assert.AreEqual(2, actual.Count);
 }
Ejemplo n.º 4
0
 public List <RoleObject> GetAll()
 {
     return(ModelRole.GetAll());
 }
Ejemplo n.º 5
0
        public void GetAll()
        {
            var models = RoleDao.GetAll();

            Assert.IsNotNull(models);
        }
Ejemplo n.º 6
0
 public List <RoleDTO> getAllR()
 {
     return(Rdao.GetAll());
 }
Ejemplo n.º 7
0
 public UserController()
 {
     _roleDao = new RoleDao();
     _userDao = new UserDao();
     _roles   = _roleDao.GetAll().ToList();
 }