Пример #1
0
        public List <CategoryJobsViewModel> getTechsByCategory(string category)
        {
            List <CategoryJobsViewModel> _techs = new List <CategoryJobsViewModel>();
            var techs = from Technician in db.Technicians
                        where Technician.JobType == category
                        select Technician;

            foreach (var item in techs)
            {
                var profile = (from TechnicianProfile in db.TechnicianProfiles
                               where TechnicianProfile.techId == item.Id
                               select TechnicianProfile).FirstOrDefault();

                CategoryJobsViewModel _model = new CategoryJobsViewModel()
                {
                    Id           = profile.Id,
                    techid       = item.Id,
                    techAspnetId = item.ApplicationUser_Id,
                    CompanyName  = item.CompanyName,
                    Rating       = profile.Rating
                };
                _techs.Add(_model);
            }

            return(_techs);
        }
        public ActionResult GetCategories(int id)
        {
            var jobs      = _context.Jobs.Where(m => m.CategoryId == id).ToList();
            var category  = _context.Categories.Find(id);
            var viewModel = new CategoryJobsViewModel {
                Jobs     = jobs,
                Category = category
            };

            return(View(viewModel));
        }