Ejemplo n.º 1
0
        public ActionResult Index(MunicipalitiesView view)
        {
            var municipalities = db.Municipalities
                                 .Include(m => m.Department)
                                 .OrderBy(m => m.Department.Name)
                                 .ThenBy(m => m.Name)
                                 .ToList();

            if (!string.IsNullOrEmpty(view.Department))
            {
                municipalities = municipalities
                                 .Where(m => m.Department.Name.ToUpper().Contains(view.Department.ToUpper()))
                                 .ToList();
            }

            if (!string.IsNullOrEmpty(view.Municipality))
            {
                municipalities = municipalities
                                 .Where(m => m.Name.ToUpper().Contains(view.Municipality.ToUpper()))
                                 .ToList();
            }

            view.Municipalities = municipalities;

            return(View(view));
        }
Ejemplo n.º 2
0
        //filter view:

        // GET: MunicipalitiesView
        public ActionResult Index()
        {
            var municipalities = db.Municipalities.Include(m => m.Department);

            var view = new MunicipalitiesView
            {
                Municipalities = municipalities.ToList(),
            };

            return(View(view));
        }
Ejemplo n.º 3
0
        // GET: Municipalities
        public ActionResult Index()
        {
            var municipalities = db.Municipalities
                                 .Include(m => m.Department)
                                 .OrderBy(m => m.Department.Name)
                                 .ThenBy(m => m.Name)
                                 .ToList();

            var view = new MunicipalitiesView
            {
                Municipalities = municipalities,
            };

            return(View(view));
        }