public ActionResult Index(Project project)
        {
            var Username = Request.Form.GetValues("Username").First();
            var Password = Request.Form.GetValues("Password").First();
            if (db.Admins.Any(it => it.Username == Username && it.Password == Password))
            {
                HttpContext.Session["Username"] = "******";
                return RedirectToAction("Index", "Admin");
            }
            else
            {
                if (db.Personels.Any(it => it.Username == Username && it.Password == Password))
                {
                    var user = db.Personels.First(it => it.Username == Username);
                    if (user.IsActive == 1)
                    {
                        HttpContext.Session["Username"] = Username;
                        HttpContext.Session["Id"] = user.PersonnelID.ToString();
                        return RedirectToAction("Index", "ProjectManager");
                    }
                    else
                    {
                        HttpContext.Session["Username"] = "******";
                        HttpContext.Session["Id"] = user.PersonnelID.ToString();
                        return RedirectToAction("Active");
                    }

                }
            }
            return View();
        }
        public ActionResult Create(Project project)
        {
            if (ModelState.IsValid)
            {
                db.Projects.Add(project);
                db.SaveChanges();

                return RedirectToAction("Index");
            }
            ViewBag.ProjectManagerID = new SelectList(db.Personels, "PersonnelID", "Name", db.Personels.ToList().First(it => it.PersonnelID == project.ProjectManagerID).PersonnelID);
            ViewBag.CategoryId = new SelectList(db.ProjectCategories, "ProjectCategoryID", "CategoryName", project.CategoryId);

            return View();
        }
 public ModelRepository()
 {
     Project = new Project();
     ProjectsList = new List<Project>();
     ProjectCategory = new ProjectCategory();
     ProjectCategoryList = new List<ProjectCategory>();
     Personel = new Personel();
     PersonelList = new List<Personel>();
     Position = new Position();
     PositionList = new List<Position>();
     Task = new Task();
     TaskList = new List<Task>();
     WorkDay = new WorkDay();
     WorkDayList = new List<WorkDay>();
 }
 public ActionResult Edit(Project project)
 {
     if (ModelState.IsValid)
     {
         db.Entry(project).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     ViewBag.ProjectManagerID = new SelectList(db.Personels, "PersonnelID", "FirstName", db.Personels.ToList().First(it => it.PersonnelID == project.ProjectManagerID).PersonnelID);
     ViewBag.CategoryId = new SelectList(db.ProjectCategories, "ProjectCategoryID", "CategoryName", project.CategoryId);
     return View(project);
 }