public ActionResult Edit(string user = "")
 {
     if (Roles.IsUserInRole("Administrator") || Roles.IsUserInRole("Job Coach") || Roles.IsUserInRole("Parent"))
     {
         MembershipUser account = System.Web.Security.Membership.GetUser(user);
         ViewData["SelectedUsers"] = db.Users.Find(account.ProviderUserKey).Users.ToList();
         ViewData["Users"]         = db.Users.ToList();
         ViewData["Jobs"]          = db.jobs.ToList();
         if (db.Users.Find(account.ProviderUserKey).jobs.Count > 0)
         {
             ViewData["SelectedJob"] = db.Users.Find(account.ProviderUserKey).jobs.ElementAt(0);
         }
         else
         {
             ViewData["SelectedJob"] = new PJCAdmin.Models.job();
         }
         if (account == null)
         {
             return(HttpNotFound());
         }
         return(View(account));
     }
     else
     {
         Response.Redirect("~/Unauthorized");
     }
     return(View());
 }
 public ActionResult Details(string user = "")
 {
     if (Roles.IsUserInRole("Administrator") || Roles.IsUserInRole("Job Coach") || Roles.IsUserInRole("Parent"))
     {
         MembershipUser account = System.Web.Security.Membership.GetUser(user);
         if (account == null)
         {
             return(HttpNotFound());
         }
         List <MembershipUser> lstUsers = new List <MembershipUser>();
         foreach (PJCAdmin.Models.User usr in db.Users.Find(System.Web.Security.Membership.GetUser(user).ProviderUserKey).Users)
         {
             lstUsers.Add(System.Web.Security.Membership.GetUser(usr.UserName));
         }
         ViewData["AssignedUsers"] = lstUsers;
         if (db.Users.Find(account.ProviderUserKey).jobs.Count > 0)
         {
             ViewData["SelectedJob"] = db.Users.Find(account.ProviderUserKey).jobs.ElementAt(0);
         }
         else
         {
             ViewData["SelectedJob"] = new PJCAdmin.Models.job();
         }
         return(View(account));
     }
     else
     {
         Response.Redirect("~/Unauthorized");
     }
     return(View());
 }
 public ActionResult Details(string user = "")
 {
     if (Roles.IsUserInRole("Administrator") || Roles.IsUserInRole("Job Coach") || Roles.IsUserInRole("Parent"))
     {
         MembershipUser account = System.Web.Security.Membership.GetUser(user);
         if (account == null)
         {
             return HttpNotFound();
         }
         List<MembershipUser> lstUsers = new List<MembershipUser>();
         foreach (PJCAdmin.Models.User usr in db.Users.Find(System.Web.Security.Membership.GetUser(user).ProviderUserKey).Users)
         {
             lstUsers.Add(System.Web.Security.Membership.GetUser(usr.UserName));
         }
         ViewData["AssignedUsers"] = lstUsers;
         if (db.Users.Find(account.ProviderUserKey).jobs.Count > 0)
             ViewData["SelectedJob"] = db.Users.Find(account.ProviderUserKey).jobs.ElementAt(0);
         else
             ViewData["SelectedJob"] = new PJCAdmin.Models.job();
         return View(account);
     }
     else
         Response.Redirect("~/Unauthorized");
     return View();
 }
        public ActionResult Create(job job, string[] taskList)
        {
            if (ModelState.IsValid)
            {



                foreach (var item in taskList)
                {
                    if (item != "false")
                        job.tasks.Add(db.tasks.Find(Convert.ToInt32(item)));
                }

                db.jobs.Add(job);

                db.SaveChanges();

                return RedirectToAction("Index");
            }

            return View(job);
        }
 public ActionResult Edit(string user = "")
 {
     if (Roles.IsUserInRole("Administrator") || Roles.IsUserInRole("Job Coach") || Roles.IsUserInRole("Parent"))
     {
         MembershipUser account = System.Web.Security.Membership.GetUser(user);
         ViewData["SelectedUsers"] = db.Users.Find(account.ProviderUserKey).Users.ToList();
         ViewData["Users"] = db.Users.ToList();
         ViewData["Jobs"] = db.jobs.ToList();
         if (db.Users.Find(account.ProviderUserKey).jobs.Count > 0)
             ViewData["SelectedJob"] = db.Users.Find(account.ProviderUserKey).jobs.ElementAt(0);
         else
             ViewData["SelectedJob"] = new PJCAdmin.Models.job();
         if (account == null)
         {
             return HttpNotFound();
         }
         return View(account);
     }
     else
         Response.Redirect("~/Unauthorized");
     return View();
 }
        public ActionResult Edit(job job, string[] taskList)
        {
            if (ModelState.IsValid)
            {
                db.jobs.Find(job.jobID).tasks.Clear();
                db.SaveChanges();
                if (taskList != null)
                {
                    foreach (var item in taskList)
                    {
                        if (item != "false")
                            db.jobs.Find(job.jobID).tasks.Add((db.tasks.Find(Convert.ToInt32(item))));

                    }
                }
                db.SaveChanges();
            }
            //return View(job);
            return RedirectToAction("Index");
        }