Exemplo n.º 1
0
        public PartialViewResult GetAllData(int section = 0)
        {
            var user = HttpContext.Session.Get <UserViewModel>(Constants.SessionKeyUserInfo);
            IEnumerable <AdvertisementsViewModel> model;

            try
            {
                model = _advertisementsHandler.GetAllData(section);
            }
            catch (DataNotFound ex)
            {
                Logger.Logger.WriteLog(Logger.Logtype.Error, ex.Message, 0, typeof(DigitalDisplayController), ex);
                ModelState.AddModelError("ErrorMessage", string.Format("{0}", ex.Message));
                model = null;
            }
            catch (Exception ex)
            {
                Logger.Logger.WriteLog(Logger.Logtype.Error, ex.Message, 0, typeof(DigitalDisplayController), ex);
                ModelState.AddModelError("ErrorMessage", string.Format("{0}", ex.Message));
                model = null;
            }
            return(PartialView("ManageAdvertisementPartial", model));
        }
        public IActionResult Index()
        {
            try
            {
                ViewBag.JobIndustryArea         = _jobpastHandler.GetJobIndustryAreaDetails();
                ViewBag.AllJobRoles             = _homeHandler.GetAllJobRoles();
                ViewBag.PopulerSearchesCategory = _homeHandler.PopulerSearchesCategory();
                ViewBag.PopulerSearchesCity     = _homeHandler.PopulerSearchesCity();
                ViewBag.TopEmployer             = _homeHandler.TopEmployer();
                List <SearchJobListViewModel> featurejobs = _homeHandler.GetFeaturedJobs();
                featurejobs = featurejobs.OrderBy(o => o.FeaturedJobDisplayOrder).ToList();
                var user = HttpContext.Session.Get <UserViewModel>(Constants.SessionKeyUserInfo);
                if (user != null)
                {
                    List <int> appliedjobs = _homeHandler.GetAplliedJobs(user.UserId);
                    for (int i = 0; i < featurejobs.Count; i++)
                    {
                        //getting the all the jobs applied by user only if the user logged in
                        if (user.UserId != 0 && appliedjobs.Count > 0)
                        {
                            featurejobs[i].IsApplied = appliedjobs.Any(aj => aj == featurejobs[i].JobPostId);
                        }
                    }
                    ViewBag.FeaturedJobs = featurejobs;
                }
                else
                {
                    ViewBag.FeaturedJobs = featurejobs;
                }

                List <SearchJobListViewModel> recentJobs = _homeHandler.GetRecentJobs();
                recentJobs = recentJobs.OrderBy(o => o.FeaturedJobDisplayOrder).ToList();
                if (user != null)
                {
                    List <int> appliedjobs = _homeHandler.GetAplliedJobs(user.UserId);
                    for (int i = 0; i < recentJobs.Count; i++)
                    {
                        //getting the all the jobs applied by user only if the user logged in
                        if (user.UserId != 0 && recentJobs.Count > 0)
                        {
                            recentJobs[i].IsApplied = appliedjobs.Any(aj => aj == recentJobs[i].JobPostId);
                        }
                    }
                    ViewBag.RecentJobs = recentJobs;
                }
                else
                {
                    ViewBag.RecentJobs = recentJobs;
                }

                List <SearchJobListViewModel> walkinJobs = _homeHandler.GetWalkInsJobs();
                ViewBag.WalkinJobs        = walkinJobs;
                ViewBag.Comment           = _homeHandler.GetSuccussStory();
                ViewBag.SuccessStoryVideo = _homeHandler.GetSuccussStoryVideos();

                //    //ViewBag.City = homeHandler.GetCityList();

                ViewBag.Section1 = _advertisementsHandler.GetAllData(1).OrderBy(o => o.Order).ToList();
                ViewBag.Section2 = _advertisementsHandler.GetAllData(2).OrderBy(o => o.Order).ToList();
                var ViewLabel = _configuration["LabelCount:Enable"];
                if (ViewLabel == "True")
                {
                    ViewBag.LabelCount = _homeHandler.GetCounterLabelData();
                }
            }
            catch (DataNotFound ex)
            {
                Logger.Logger.WriteLog(Logger.Logtype.Error, ex.Message, 0, typeof(HomeController), ex);
                ModelState.AddModelError("ErrorMessage", string.Format("{0}", ex.Message));
            }
            catch (Exception ex)
            {
                Logger.Logger.WriteLog(Logger.Logtype.Error, ex.Message, 0, typeof(HomeController), ex);
                ModelState.AddModelError("ErrorMessage", string.Format("{0}", ex.Message));
            }
            return(View());
        }