Ejemplo n.º 1
0
        public ActionResult Create([Bind(Include = "Id,Title,Description,TotalHours")] job job)
        {
            //employeeId,employerId
            if (ModelState.IsValid)
            {
                RolesManager roles = new RolesManager();
                job.employeeId = roles.getUserId(System.Web.HttpContext.Current.User.Identity.Name);
                db.job.Add(job);
                db.SaveChanges();
                return RedirectToAction("GetMyJobs");
            }

            return View(job);
        }
Ejemplo n.º 2
0
        public ActionResult Create([Bind(Include = "Id,Title,Description,TotalHoursWorked,PricePerHour")] job job, string employer)
        {
            if (ModelState.IsValid)
            {
                RolesManager roles = new RolesManager();
                job.employeeId = roles.getUserId(System.Web.HttpContext.Current.User.Identity.Name);
                job.employerId = employer;
                db.job.Add(job);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(job);
        }
Ejemplo n.º 3
0
 public ActionResult GetMyJobs()
 {
     RolesManager roles = new RolesManager();
     var rolename = roles.getUserRole(System.Web.HttpContext.Current.User.Identity.Name);
     if (rolename == "employer")
     {
         string userId = roles.getUserId(System.Web.HttpContext.Current.User.Identity.Name);
         try
         {
             return View(db.job.Where(m => m.employerId.ToString() == userId));
         }
         catch (Exception)
         {
             return View();
         }
     }
     else
     {
         string userId = roles.getUserId(System.Web.HttpContext.Current.User.Identity.Name);
         try
         {
             return View(db.job.Where(m => m.employeeId.ToString() == userId));
         }
         catch (Exception)
         {
             return View();
         }
     }
 }
Ejemplo n.º 4
0
        public ActionResult MyJobs()
        {
            var all_jobs = db.job.ToList();
            List<job> thisUserJobs = new List<job>();
            foreach (var job in all_jobs)
            {
                var name = System.Web.HttpContext.Current.User.Identity.Name;
                RolesManager role = new RolesManager();
                var userId = role.getUserId(name);
                if (job.employerId == userId)
                {
                    thisUserJobs.Add(job);
                }
            }

            return View(thisUserJobs);
        }