예제 #1
0
        // GET: /T_CardEmplGrp/
        public ActionResult Index(string currentFilter, string searchString, string sortBy, string isAsc, int?page, int?itemsPerPage, string HostingEntity, int?HostingEntityID, string AssociatedType, bool?IsExport, bool?IsDeepSearch, bool?IsFilter, bool?RenderPartial, string BulkOperation, string parent, string Wfsearch, string caller, bool?BulkAssociate, string viewtype, string isMobileHome, bool?IsHomeList)
        {
            if (string.IsNullOrEmpty(isAsc) && !string.IsNullOrEmpty(sortBy))
            {
                isAsc = "ASC";
            }
            ViewBag.isAsc               = isAsc;
            ViewBag.CurrentSort         = sortBy;
            ViewData["HostingEntity"]   = HostingEntity;
            ViewData["HostingEntityID"] = HostingEntityID;
            ViewData["AssociatedType"]  = AssociatedType;
            ViewData["IsFilter"]        = IsFilter;
            ViewData["BulkOperation"]   = BulkOperation;
            ViewData["caller"]          = caller;
            if (!string.IsNullOrEmpty(viewtype))
            {
                viewtype = viewtype.Replace("?IsAddPop=true", "");
                ViewBag.TemplatesName = viewtype;
            }
            if (searchString != null)
            {
                page = null;
            }
            else
            {
                searchString = currentFilter;
            }
            ViewBag.CurrentFilter = searchString;
            CustomLoadViewDataListOnIndex(HostingEntity, HostingEntityID, AssociatedType);
            var lstT_CardEmplGrp = from s in db.T_CardEmplGrps
                                   select s;

            if (!String.IsNullOrEmpty(searchString))
            {
                lstT_CardEmplGrp = searchRecords(lstT_CardEmplGrp, searchString.ToUpper(), IsDeepSearch);
            }
            if (parent != null && parent == "Home")
            {
                ViewBag.Homeval = searchString;
            }
            if (!String.IsNullOrEmpty(sortBy) && !String.IsNullOrEmpty(isAsc))
            {
                lstT_CardEmplGrp = sortRecords(lstT_CardEmplGrp, sortBy, isAsc);
            }
            else
            {
                lstT_CardEmplGrp = lstT_CardEmplGrp.OrderByDescending(c => c.Id);
            }
            lstT_CardEmplGrp = CustomSorting(lstT_CardEmplGrp);
            int pageSize   = 10;
            int pageNumber = (page ?? 1);

            ViewBag.Pages = page;
            if (itemsPerPage != null)
            {
                pageSize = (int)itemsPerPage;
                ViewBag.CurrentItemsPerPage = itemsPerPage;
            }
            //Cookies for pagesize
            if (Request.Cookies["pageSize" + HttpUtility.UrlEncode(User.Name) + "T_CardEmplGrp"] != null)
            {
                pageSize = Convert.ToInt32(Request.Cookies["pageSize" + HttpUtility.UrlEncode(User.Name) + "T_CardEmplGrp"].Value);
                ViewBag.CurrentItemsPerPage = itemsPerPage;
            }
            pageSize = pageSize > 100 ? 100 : pageSize;
            //Cookies for pagination
            if (Request.Cookies["pagination" + HttpUtility.UrlEncode(User.Name) + "T_CardEmplGrp"] != null)
            {
                pageNumber    = Convert.ToInt32(Request.Cookies["pagination" + HttpUtility.UrlEncode(User.Name) + "T_CardEmplGrp"].Value);
                ViewBag.Pages = pageNumber;
            }
            //
            //
            ViewBag.PageSize = pageSize;
            var _T_CardEmplGrp = lstT_CardEmplGrp;

            if (Convert.ToBoolean(IsExport))
            {
                if (!((CustomPrincipal)User).CanUseVerb("ExportExcel", "T_CardEmplGrp", User) || !User.CanView("T_CardEmplGrp"))
                {
                    return(RedirectToAction("Index", "Error"));
                }
                pageNumber = 1;
                if (_T_CardEmplGrp.Count() > 0)
                {
                    pageSize = _T_CardEmplGrp.Count();
                }
                return(View("ExcelExport", _T_CardEmplGrp.ToPagedList(pageNumber, pageSize)));
            }
            else
            {
                if (pageNumber > 1)
                {
                    var totalListCount = _T_CardEmplGrp.Count();
                    int quotient       = totalListCount / pageSize;
                    var remainder      = totalListCount % pageSize;
                    var maxpagenumber  = quotient + (remainder > 0 ? 1 : 0);
                    if (pageNumber > maxpagenumber)
                    {
                        pageNumber = 1;
                    }
                }
            }
            if (!(RenderPartial == null?false:RenderPartial.Value) && !Request.IsAjaxRequest())
            {
                if (string.IsNullOrEmpty(viewtype))
                {
                    viewtype = "IndexPartial";
                }
                GetTemplatesForList(viewtype);
                if ((ViewBag.TemplatesName != null && viewtype != null) && ViewBag.TemplatesName != viewtype)
                {
                    ViewBag.TemplatesName = viewtype;
                }
                var list = _T_CardEmplGrp.ToPagedList(pageNumber, pageSize);
                ViewBag.EntityT_CardEmplGrpDisplayValue = new SelectList(list.Select(z => new { ID = z.Id, DisplayValue = z.DisplayValue }), "ID", "DisplayValue");
                TempData["T_CardEmplGrplist"]           = list.Select(z => new { ID = z.Id, DisplayValue = z.DisplayValue });
                return(View(list));
            }
            else
            {
                if (BulkOperation != null && (BulkOperation == "single" || BulkOperation == "multiple"))
                {
                    ViewData["BulkAssociate"] = BulkAssociate;
                    if (!string.IsNullOrEmpty(caller))
                    {
                        FilterApplicationDropdowns _fad = new FilterApplicationDropdowns();
                        _T_CardEmplGrp = _fad.FilterDropdown <T_CardEmplGrp>(User, _T_CardEmplGrp, "T_CardEmplGrp", caller);
                    }
                    if (Convert.ToBoolean(BulkAssociate))
                    {
                        if (!String.IsNullOrEmpty(sortBy) && !String.IsNullOrEmpty(isAsc))
                        {
                            return(PartialView("BulkOperation", sortRecords(lstT_CardEmplGrp.Except(_T_CardEmplGrp), sortBy, isAsc).ToPagedList(pageNumber, pageSize)));
                        }
                        else
                        {
                            return(PartialView("BulkOperation", lstT_CardEmplGrp.Except(_T_CardEmplGrp).OrderBy(q => q.DisplayValue).ToPagedList(pageNumber, pageSize)));
                        }
                    }
                    else
                    {
                        if (!String.IsNullOrEmpty(sortBy) && !String.IsNullOrEmpty(isAsc))
                        {
                            return(PartialView("BulkOperation", _T_CardEmplGrp.ToPagedList(pageNumber, pageSize)));
                        }
                        else
                        {
                            return(PartialView("BulkOperation", _T_CardEmplGrp.OrderBy(q => q.DisplayValue).ToPagedList(pageNumber, pageSize)));
                        }
                    }
                }
                else
                {
                    if (ViewBag.TemplatesName == null)
                    {
                        if (!string.IsNullOrEmpty(isMobileHome))
                        {
                            pageSize = _T_CardEmplGrp.Count() == 0 ? 1 : _T_CardEmplGrp.Count();
                        }
                        ViewData["HomePartialList"] = IsHomeList;
                        var list = _T_CardEmplGrp.ToPagedList(pageNumber, Convert.ToBoolean(IsHomeList) ? 5 : pageSize);
                        ViewBag.EntityT_CardEmplGrpDisplayValue = new SelectList(list.Select(z => new { ID = z.Id, DisplayValue = z.DisplayValue }), "ID", "DisplayValue");
                        TempData["T_CardEmplGrplist"]           = list.Select(z => new { ID = z.Id, DisplayValue = z.DisplayValue });
                        return(PartialView(Convert.ToBoolean(IsHomeList) ? "HomePartialList" : "IndexPartial", list));
                    }
                    else
                    {
                        if (!string.IsNullOrEmpty(isMobileHome))
                        {
                            pageSize = _T_CardEmplGrp.Count() == 0 ? 1 : _T_CardEmplGrp.Count();
                        }
                        var list = _T_CardEmplGrp.ToPagedList(pageNumber, pageSize);
                        ViewBag.EntityT_CardEmplGrpDisplayValue = new SelectList(list.Select(z => new { ID = z.Id, DisplayValue = z.DisplayValue }), "ID", "DisplayValue");
                        TempData["T_CardEmplGrplist"]           = list.Select(z => new { ID = z.Id, DisplayValue = z.DisplayValue });
                        return(PartialView(ViewBag.TemplatesName, list));
                    }
                }
            }
        }
        // GET: /T_MonthlyRepeatType/
        public ActionResult Index(string currentFilter, string searchString, string sortBy, string isAsc, int?page, int?itemsPerPage, string HostingEntity, int?HostingEntityID, string AssociatedType, bool?IsExport, bool?IsDeepSearch, bool?IsFilter, bool?RenderPartial, string BulkOperation, string parent, string Wfsearch, string caller, bool?BulkAssociate, string viewtype)
        {
            if (string.IsNullOrEmpty(isAsc) && !string.IsNullOrEmpty(sortBy))
            {
                isAsc = "ASC";
            }
            ViewBag.isAsc               = isAsc;
            ViewBag.CurrentSort         = sortBy;
            ViewData["HostingEntity"]   = HostingEntity;
            ViewData["HostingEntityID"] = HostingEntityID;
            ViewData["AssociatedType"]  = AssociatedType;
            ViewData["IsFilter"]        = IsFilter;
            ViewData["BulkOperation"]   = BulkOperation;
            ViewData["caller"]          = caller;
            if (!string.IsNullOrEmpty(viewtype))
            {
                viewtype = viewtype.Replace("?IsAddPop=true", "");
                ViewBag.TemplatesName = viewtype;
            }
            if (searchString != null)
            {
                page = null;
            }
            else
            {
                searchString = currentFilter;
            }
            ViewBag.CurrentFilter = searchString;
            var lstT_MonthlyRepeatType = from s in db.T_MonthlyRepeatTypes
                                         select s;

            if (!String.IsNullOrEmpty(searchString))
            {
                lstT_MonthlyRepeatType = searchRecords(lstT_MonthlyRepeatType, searchString.ToUpper(), IsDeepSearch);
            }
            if (parent != null && parent == "Home")
            {
                ViewBag.Homeval = searchString;
            }
            if (!String.IsNullOrEmpty(sortBy) && !String.IsNullOrEmpty(isAsc))
            {
                lstT_MonthlyRepeatType = sortRecords(lstT_MonthlyRepeatType, sortBy, isAsc);
            }
            else
            {
                lstT_MonthlyRepeatType = lstT_MonthlyRepeatType.OrderByDescending(c => c.Id);
            }
            int pageSize   = 10;
            int pageNumber = (page ?? 1);

            ViewBag.Pages = page;
            if (itemsPerPage != null)
            {
                pageSize = (int)itemsPerPage;
                ViewBag.CurrentItemsPerPage = itemsPerPage;
            }
            //Cookies for pagesize
            if (Request.Cookies["pageSize" + HttpUtility.UrlEncode(User.Name) + "T_MonthlyRepeatType"] != null)
            {
                pageSize = Convert.ToInt32(Request.Cookies["pageSize" + HttpUtility.UrlEncode(User.Name) + "T_MonthlyRepeatType"].Value);
                ViewBag.CurrentItemsPerPage = itemsPerPage;
            }
            pageSize = pageSize > 100 ? 100 : pageSize;
            //Cookies for pagination
            if (Request.Cookies["pagination" + HttpUtility.UrlEncode(User.Name) + "T_MonthlyRepeatType"] != null)
            {
                pageNumber    = Convert.ToInt32(Request.Cookies["pagination" + HttpUtility.UrlEncode(User.Name) + "T_MonthlyRepeatType"].Value);
                ViewBag.Pages = pageNumber;
            }
            //
            //
            var _T_MonthlyRepeatType = lstT_MonthlyRepeatType;

            if (Convert.ToBoolean(IsExport))
            {
                pageNumber = 1;
                if (_T_MonthlyRepeatType.Count() > 0)
                {
                    pageSize = _T_MonthlyRepeatType.Count();
                }
                return(View("ExcelExport", _T_MonthlyRepeatType.ToPagedList(pageNumber, pageSize)));
            }
            if (!(RenderPartial == null?false:RenderPartial.Value) && !Request.IsAjaxRequest())
            {
                GetTemplatesForList();
                if ((ViewBag.TemplatesName != null && viewtype != null) && ViewBag.TemplatesName != viewtype)
                {
                    ViewBag.TemplatesName = viewtype;
                }
                return(View(_T_MonthlyRepeatType.ToPagedList(pageNumber, pageSize)));
            }
            else
            {
                if (BulkOperation != null && (BulkOperation == "single" || BulkOperation == "multiple"))
                {
                    ViewData["BulkAssociate"] = BulkAssociate;
                    if (caller != "")
                    {
                        FilterApplicationDropdowns _fad = new FilterApplicationDropdowns();
                        _T_MonthlyRepeatType = _fad.FilterDropdown <T_MonthlyRepeatType>(User, _T_MonthlyRepeatType, "T_MonthlyRepeatType", caller);
                    }
                    if (Convert.ToBoolean(BulkAssociate))
                    {
                        if (!String.IsNullOrEmpty(sortBy) && !String.IsNullOrEmpty(isAsc))
                        {
                            return(PartialView("BulkOperation", sortRecords(lstT_MonthlyRepeatType.Except(_T_MonthlyRepeatType), sortBy, isAsc).ToPagedList(pageNumber, pageSize)));
                        }
                        else
                        {
                            return(PartialView("BulkOperation", lstT_MonthlyRepeatType.Except(_T_MonthlyRepeatType).OrderBy(q => q.DisplayValue).ToPagedList(pageNumber, pageSize)));
                        }
                    }
                    else
                    {
                        if (!String.IsNullOrEmpty(sortBy) && !String.IsNullOrEmpty(isAsc))
                        {
                            return(PartialView("BulkOperation", _T_MonthlyRepeatType.ToPagedList(pageNumber, pageSize)));
                        }
                        else
                        {
                            return(PartialView("BulkOperation", _T_MonthlyRepeatType.OrderBy(q => q.DisplayValue).ToPagedList(pageNumber, pageSize)));
                        }
                    }
                }
                else
                {
                    if (ViewBag.TemplatesName == null)
                    {
                        return(PartialView("IndexPartial", _T_MonthlyRepeatType.ToPagedList(pageNumber, pageSize)));
                    }
                    else
                    {
                        return(PartialView(ViewBag.TemplatesName, _T_MonthlyRepeatType.ToPagedList(pageNumber, pageSize)));
                    }
                }
            }
        }
        // GET: /PropertyMapping/
        public ActionResult Index(string currentFilter, string searchString, string sortBy, string isAsc, int?page, int?itemsPerPage, string HostingEntity, int?HostingEntityID, string AssociatedType, bool?IsExport, bool?IsDeepSearch, bool?IsFilter, bool?RenderPartial, string BulkOperation, string parent, string Wfsearch, string caller, bool?BulkAssociate)
        {
            if (string.IsNullOrEmpty(isAsc) && !string.IsNullOrEmpty(sortBy))
            {
                isAsc = "ASC";
            }
            ViewBag.isAsc               = isAsc;
            ViewBag.CurrentSort         = sortBy;
            ViewData["HostingEntity"]   = HostingEntity;
            ViewData["HostingEntityID"] = HostingEntityID;
            ViewData["AssociatedType"]  = AssociatedType;
            ViewData["IsFilter"]        = IsFilter;
            ViewData["BulkOperation"]   = BulkOperation;
            ViewData["caller"]          = caller;
            if (searchString != null)
            {
                page = null;
            }
            else
            {
                searchString = currentFilter;
            }
            ViewBag.CurrentFilter = searchString;
            var lstPropertyMapping = from s in db.PropertyMappings
                                     select s;

            if (!String.IsNullOrEmpty(searchString))
            {
                lstPropertyMapping = searchRecords(lstPropertyMapping, searchString.ToUpper(), IsDeepSearch);
            }
            if (parent != null && parent == "Home")
            {
                ViewBag.Homeval = searchString;
            }
            if (!String.IsNullOrEmpty(sortBy) && !String.IsNullOrEmpty(isAsc))
            {
                lstPropertyMapping = sortRecords(lstPropertyMapping, sortBy, isAsc);
            }
            else
            {
                lstPropertyMapping = lstPropertyMapping.OrderByDescending(c => c.Id);
            }
            int pageSize   = 10;
            int pageNumber = (page ?? 1);

            ViewBag.Pages = page;
            if (itemsPerPage != null)
            {
                pageSize = (int)itemsPerPage;
                ViewBag.CurrentItemsPerPage = itemsPerPage;
            }
            //Cookies for pagesize
            if (Request.Cookies["pageSize" + HttpUtility.UrlEncode(User.Name) + "PropertyMapping"] != null)
            {
                pageSize = Convert.ToInt32(Request.Cookies["pageSize" + HttpUtility.UrlEncode(User.Name) + "PropertyMapping"].Value);
                ViewBag.CurrentItemsPerPage = itemsPerPage;
            }
            pageSize = pageSize > 100 ? 100 : pageSize;
            //Cookies for pagination
            if (Request.Cookies["pagination" + HttpUtility.UrlEncode(User.Name) + "PropertyMapping"] != null)
            {
                pageNumber    = Convert.ToInt32(Request.Cookies["pagination" + HttpUtility.UrlEncode(User.Name) + "PropertyMapping"].Value);
                ViewBag.Pages = pageNumber;
            }
            //
            //
            var _PropertyMapping = lstPropertyMapping.Include(t => t.entitypropertymapping);

            if (HostingEntity == "EntityDataSource" && AssociatedType == "EntityPropertyMapping")
            {
                if (HostingEntityID != null)
                {
                    long hostid = Convert.ToInt64(HostingEntityID);
                    _PropertyMapping = _PropertyMapping.Where(p => p.EntityPropertyMappingID == hostid);
                }
                else
                {
                    _PropertyMapping = _PropertyMapping.Where(p => p.EntityPropertyMappingID == null);
                }
            }

            if (Convert.ToBoolean(IsExport))
            {
                pageNumber = 1;
                if (_PropertyMapping.Count() > 0)
                {
                    pageSize = _PropertyMapping.Count();
                }
                return(View("ExcelExport", _PropertyMapping.ToPagedList(pageNumber, pageSize)));
            }
            if (!(RenderPartial == null ? false : RenderPartial.Value) && !Request.IsAjaxRequest())
            {
                return(View(_PropertyMapping.ToPagedList(pageNumber, pageSize)));
            }
            else
            {
                if (BulkOperation != null && (BulkOperation == "single" || BulkOperation == "multiple"))
                {
                    ViewData["BulkAssociate"] = BulkAssociate;
                    if (caller != "")
                    {
                        FilterApplicationDropdowns _fad = new FilterApplicationDropdowns();
                        _PropertyMapping = _fad.FilterDropdown <PropertyMapping>(User, _PropertyMapping, "PropertyMapping", caller);
                    }
                    if (Convert.ToBoolean(BulkAssociate))
                    {
                        if (!String.IsNullOrEmpty(sortBy) && !String.IsNullOrEmpty(isAsc))
                        {
                            return(PartialView("BulkOperation", sortRecords(lstPropertyMapping.Except(_PropertyMapping), sortBy, isAsc).ToPagedList(pageNumber, pageSize)));
                        }
                        else
                        {
                            return(PartialView("BulkOperation", lstPropertyMapping.Except(_PropertyMapping).OrderBy(q => q.DisplayValue).ToPagedList(pageNumber, pageSize)));
                        }
                    }
                    else
                    {
                        if (!String.IsNullOrEmpty(sortBy) && !String.IsNullOrEmpty(isAsc))
                        {
                            return(PartialView("BulkOperation", _PropertyMapping.ToPagedList(pageNumber, pageSize)));
                        }
                        else
                        {
                            return(PartialView("BulkOperation", _PropertyMapping.OrderBy(q => q.DisplayValue).ToPagedList(pageNumber, pageSize)));
                        }
                    }
                }
                else
                {
                    return(PartialView("IndexPartial", _PropertyMapping.ToPagedList(pageNumber, pageSize)));
                }
            }
        }