public ActionResult ManageCompany(int?page, int id = 0) //id: company type id
        {
            var currentParent = new Company_Type {
                Status = (int)EntityStatus.Visible
            };
            var list = GetCompaniesByType(ref currentParent, id);

            if (currentParent == null || !currentParent.IsValid())
            {
                return(RedirectToError("Class is not valid!"));
            }

            //return ManageModel(new Company
            //{
            //    Company_Type_Id = currentParent.Id
            //}, page, list: list,
            //currentParentId: currentParent.Id, currentParentName: currentParent.Company_Type_Name,
            //filterpartial_name: "_partial_Filter_SearchModel");
            return(ManageModel(new Company
            {
                Company_Type_Id = currentParent.Id
            }, page, list: list,
                               entityName: "Center",
                               currentParentId: currentParent.Id, currentParentName: currentParent.Company_Type_Name,
                               filterSearch: SearchModelEnum.ByNameWithParent));
        }
        public ActionResult FilterCompany(//dùng model để generic
            int?page,
            int?page_size,
            int pageChange,
            string entity,

            int id = 0,

            string Model_Name  = "",
            string sort_target = "",
            bool sort_rank     = false)
        {
            int pageSize   = (page_size ?? PAGE_SIZE_LARGE_20);
            int pageNumber = (page ?? 1);

            if (pageChange == 0)
            {
                pageNumber = 1;
            }

            var currentParent = new Company_Type {
                Status = (int)EntityStatus.Visible
            };
            var items = GetCompaniesByType(ref currentParent, id);

            if (currentParent == null || !currentParent.IsValid())
            {
                return(RedirectToError("Company Type is not valid!"));
            }

            //var items = IoCConfig.Service<IClassService>().FindAllValid();//sửa
            if (Model_Name != "")
            {
                pageNumber = 1;
                var name = Model_Name;
                name  = name.ToLower().Convert_Chuoi_Khong_Dau();
                items = items.Where(c => c.Company_Name.ToLower().Convert_Chuoi_Khong_Dau().Contains(name));
            }
            else//sửa
            {
            }

            ViewBag.sort_target = sort_target;
            ViewBag.sort_rank   = sort_rank ? "asc" : "desc";

            return(ReturnPartialView(entity, items, pageNumber, pageSize));
        }
        private IEnumerable <Company> GetCompaniesByType(ref Company_Type currentParent, int id = 0)
        {
            IEnumerable <Company> list = null;

            if (id != 0)
            {
                currentParent = IoCConfig.Service <ICompany_TypeService>().FindById(id);
                if (currentParent != null && currentParent.IsValid())
                {
                    list = currentParent.Companies;
                }
            }
            else
            {
                list = IoCConfig.Service <ICompanyService>().FindAllValid();
            }

            return(list);
        }
 public ActionResult EditCompany_Type(Company_Type model)
 {
     return(EditModel(model));
 }
 public ActionResult AddCompany_Type(Company_Type model)
 {
     return(AddModel(model));
 }