Beispiel #1
0
        public ActionResult EditRole(string Id, string Name)
        {
            string userkey   = ConfigurationManager.AppSettings["userkey"];
            string uid       = ConfigurationManager.AppSettings["uid"];
            string LoginUser = (string)Session["LoginSAPID"];

            try
            {
                Employer.Employer employer = new Employer.Employer();
                DataTable         dt       = employer.FetchViews(userkey, uid);
                dt.TableName = "AdminViews";
                dt.Columns.ToString();


                var adminViews = (from DataRow dr in dt.Rows
                                  select new AdminViews()
                {
                    ID = dr["MenuID"].ToString(),
                    MenuName = dr["MenuName"].ToString(),
                    ControllerName = dr["Controller"].ToString(),
                    ActionName = dr["Action"].ToString(),
                }).ToList();

                ViewData.Model = adminViews;

                ViewBag.ParentId = adminViews;

                return(View());
            }
            catch (Exception ex)
            {
                LogError logerror = new LogError();
                logerror.ErrorLog("", LoginUser, "", "AdminViews/EditRole", "AdminViews", "EditRole", "FetchViews Error", ex.Message.ToString(), 0);
                TempData["error"] = ex.Message.ToString();
                ViewBag.Error     = TempData["error"];
                return(View());
            }
        }
Beispiel #2
0
        public JsonResult GetAllViews()
        {
            string userkey   = ConfigurationManager.AppSettings["userkey"];
            string uid       = ConfigurationManager.AppSettings["uid"];
            string LoginUser = (string)Session["LoginSAPID"];

            Employer.Employer employer = new Employer.Employer();
            DataTable         dt       = employer.FetchViews(userkey, uid);

            dt.TableName = "AdminViews";
            dt.Columns.ToString();

            var adminViews = (from DataRow dr in dt.Rows
                              select new AdminViews()
            {
                ID = dr["MenuID"].ToString(),
                MenuName = dr["MenuName"].ToString(),
                ControllerName = dr["Controller"].ToString(),
                ActionName = dr["Action"].ToString(),
            }).ToList();

            return(Json(new { data = adminViews }, JsonRequestBehavior.AllowGet));
        }
Beispiel #3
0
        public JsonResult GetAdminViews([ModelBinder(typeof(DataTablesBinder))] IDataTablesRequest requestModel)
        {
            string userkey   = ConfigurationManager.AppSettings["userkey"];
            string uid       = ConfigurationManager.AppSettings["uid"];
            string LoginUser = (string)Session["LoginSAPID"];

            try
            {
                Employer.Employer employer = new Employer.Employer();
                DataTable         dt       = employer.FetchViews(userkey, uid);
                dt.TableName = "AdminViews";
                dt.Columns.ToString();
                List <AdminViews> adminViews = new List <AdminViews>();
                int startRec = requestModel.Start;
                int pageSize = requestModel.Length;


                List <AdminViews> viewsCount = (from DataRow dr in dt.Rows
                                                select new AdminViews()
                {
                    MenuName = dr["MenuName"].ToString()
                }).ToList();

                adminViews = (from DataRow dr in dt.Rows
                              select new AdminViews()
                {
                    MenuName = dr["MenuName"].ToString(),
                    ControllerName = dr["Controller"].ToString(),
                    ActionName = dr["Action"].ToString(),
                }).Skip(startRec).Take(pageSize).ToList();

                var totalCount    = viewsCount.Count();
                var filteredCount = adminViews.Count();

                /*if (requestModel.Search.Value != string.Empty)
                 * {
                 *  var value = requestModel.Search.Value.Trim();
                 *
                 *  employeeCount = (from DataRow dr in dt.Rows
                 *                   where dr["P_I_N"].ToString().ToString().Contains(value) || dr["First Name"].ToString().Contains(value)
                 || dr["Last Name"].ToString().Contains(value) || dr["Phone No"].ToString().Contains(value)
                 || dr["E-mail"].ToString().Contains(value)
                 ||                  select new CompanyEmployee()
                 ||                  {
                 ||                      PIN = dr["P_I_N"].ToString()
                 ||                  }).ToList();
                 ||
                 || companyEmployee = (from DataRow dr in dt.Rows
                 ||                    where dr["P_I_N"].ToString().ToString().Contains(value) || dr["First Name"].ToString().Contains(value)
                 || dr["Last Name"].ToString().Contains(value) || dr["Phone No"].ToString().Contains(value)
                 || dr["E-mail"].ToString().Contains(value)
                 ||                    select new CompanyEmployee()
                 ||                    {
                 ||                        PIN = dr["P_I_N"].ToString(),
                 ||                        FirstName = dr["First Name"].ToString(),
                 ||                        LastName = dr["Last Name"].ToString(),
                 ||                        MiddleName = dr["Middle Names"].ToString(),
                 ||                        PhoneNo = dr["Mobile 1"].ToString(),
                 ||                        DateOfBirth = dr["Date Of Birth"].ToString(),
                 ||                        DateOfEmployment = dr["Date Of Employment"].ToString(),
                 ||                        Email = dr["E-mail"].ToString(),
                 ||                    }).Skip(startRec).Take(pageSize).ToList();
                 ||
                 || totalCount = employeeCount.Count();
                 || filteredCount = companyEmployee.Count();
                 ||}*/

                var sortedColumns = requestModel.Columns.GetSortedColumns();
                var orderByString = String.Empty;

                foreach (var column in sortedColumns)
                {
                    orderByString += orderByString != String.Empty ? "," : "";
                    orderByString += (column.Data) + (column.SortDirection == Column.OrderDirection.Ascendant ? " asc" : " desc");
                }

                var data = adminViews.Select(emList => new
                {
                    MenuName       = emList.MenuName,
                    ControllerName = emList.ControllerName,
                    ActionName     = emList.ActionName
                }).ToList();

                return(Json(new DataTablesResponse(requestModel.Draw, data, totalCount, totalCount), JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                LogError logerror = new LogError();
                logerror.ErrorLog("", LoginUser, "", "AdminViewsController/GetAdminViews", "AdminViewsController", "GetAdminViews", "FetchViews Error", ex.Message.ToString(), 0);
                throw new Exception(ex.Message.ToString());
            }
        }