Ejemplo n.º 1
0
        public ActionResult employer_profile(int?emp_id)
        {
            if (emp_id.HasValue)
            {
                int emp_id_ = Convert.ToInt32(emp_id);
                var b       = (from p in db.employer_info
                               join q in db.company_type on p.company_type equals q.id
                               where p.emp_id == emp_id_
                               select new { p, q.category_name }).FirstOrDefault();
                employerList e = new employerList();
                e.Address       = b.p.address;
                e.category_name = b.category_name;
                e.company_name  = b.p.company_name;
                e.created_at    = DateTime.Parse(b.p.created_at.ToString());
                e.description   = b.p.description;
                e.email         = b.p.email;
                e.contact       = b.p.contact;
                e.logo          = b.p.logo;
                e.emp_id        = b.p.emp_id;

                List <job> job = new List <Models.job>();
                job = db.jobs.Where(a => a.status == 1 && a.employer == emp_id_).Take(5).ToList();
                ViewBag.postedjobs = db.jobs.Where(a => a.status == 1 && a.employer == emp_id_).Count();
                List <job_model> jobs = new List <job_model>();
                foreach (var item in job)
                {
                    job_model jobmodel = new job_model();
                    jobmodel.category    = item.category.ToString();
                    jobmodel.city        = item.city;
                    jobmodel.created_at  = item.created_at;
                    jobmodel.description = item.description;
                    jobmodel.district    = item.district;
                    var name = db.employer_info
                               .Where(c => c.emp_id == item.employer)
                               .Select(cc => cc.company_name)
                               .SingleOrDefault();
                    jobmodel.employer     = name.ToString();
                    jobmodel.full_address = item.full_address;
                    jobmodel.state        = item.state;
                    jobmodel.district     = item.district;
                    jobmodel.job_id       = item.job_id;
                    jobmodel.title        = item.title;
                    jobmodel.job_type     = item.job_type;
                    var image = db.employer_info
                                .Where(c => c.emp_id == item.employer)
                                .Select(cc => cc.logo)
                                .SingleOrDefault();
                    jobmodel.image    = image;
                    jobmodel.category = db.job_categories.Find(Convert.ToInt32(item.category)).category_name.ToString();
                    jobs.Add(jobmodel);
                }
                ViewBag.jobs = jobs;
                return(View(e));
            }
            else
            {
                return(Json("Restricted Access", JsonRequestBehavior.AllowGet));
            }
        }
Ejemplo n.º 2
0
        public ActionResult employer_listajax(int?page, string time = "", string cat = "", string searchkey = "", string display = "")
        {
            if (display == "" || display == "grid")
            {
                ViewBag.display = "grid";
            }
            else
            {
                ViewBag.display = "list";
            }
            DateTime today = DateTime.Now;
            int      span;
            int      pageSize  = 15;
            int      pageIndex = 1;
            var      predicate = PredicateBuilder.New <employer_info>(true);

            if (!string.IsNullOrEmpty(cat))
            {
                string[] cat_ = cat.Split(',');
                foreach (var i in cat_)
                {
                    int j = (Convert.ToInt16(i));
                    predicate = predicate.Or(p => p.company_type == j);
                }
            }
            predicate.And(p => p.company_name.Contains(searchkey));
            predicate = predicate.And(a => a.status == "ACTIVE");
            pageIndex = page.HasValue ? Convert.ToInt16(page) : 1;
            var emp = db.employer_info.Where(predicate).Join(db.company_type, p => p.company_type, pc => pc.id, (p, pc) => new { p = p, category_name = pc.category_name }).ToList();
            //var emp = (from p in db.employer_info
            //join q in db.company_type on p.company_type equals q.id
            //select new { p, q.category_name }
            //).ToList();
            List <employerList> data = new List <employerList>();

            foreach (var item in emp)
            {
                employerList e = new employerList();
                e.category_name = item.category_name;
                e.emp_id        = item.p.emp_id;
                e.logo          = item.p.logo;
                e.company_name  = item.p.company_name;
                e.postedjobs    = db.jobs.Where(a => a.employer == e.emp_id && a.status == 1).Count();
                e.Address       = item.p.address;
                e.email         = item.p.email;
                e.updated_at    = DateTime.Parse(item.p.updated_at.ToString());
                e.company_type  = item.p.company_type.HasValue ? Convert.ToInt16(item.p.company_type) : 0;
                data.Add(e);
            }
            if (!string.IsNullOrEmpty(time))
            {
                if (time == "all")
                {
                    span = 2500000;
                }
                else
                {
                    span = Convert.ToInt32(time);
                }
                foreach (var variable in data.ToList())
                {
                    TimeSpan t    = (today - Convert.ToDateTime(variable.updated_at));
                    double   days = t.TotalHours;
                    if (!(days <= span))
                    {
                        data.Remove(variable);
                    }
                }
            }
            return(PartialView(data.ToPagedList(pageIndex, pageSize)));
        }