Exemplo n.º 1
0
        public ActionResult Delete(int id)

        {
            if (Session["empName"] != null)
            {
                string name = Session["empName"].ToString();

                var         ss    = _db.Employee.Where(d => d.employeeName == name).FirstOrDefault();
                string      empid = ss.id.ToString();
                HowCanAcess _hca  = _db.HowCanAcess.Where(s => s.employeeID.ToString() == empid).FirstOrDefault();

                if (id == null)
                {
                    return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
                }
                Employees emp = _db.Employee.Find(id);
                if (emp == null)
                {
                    return(HttpNotFound());
                }
                else if (_hca.Employee == true)
                {
                    var model = new EmpOfficeJob();
                    model.EmpY    = emp;
                    model.JobX    = _db.Jobs.ToList();
                    model.OfficeX = _db.Offices.ToList();
                    return(View(model));
                }
            }
            return(RedirectToAction("HavntAccess", "Employees"));
        }
Exemplo n.º 2
0
        public ActionResult Index()
        {
            var model = new EmpOfficeJob();

            model.JobX    = _db.Jobs.ToList();
            model.OfficeX = _db.Offices.ToList();
            model.hcaX    = _db.HowCanAcess.ToList();

            if (Session["empName"] != null)
            {
                string name = Session["empName"].ToString();

                var ss = _db.Employee.Where(d => d.employeeName == name).FirstOrDefault();

                var _allowAll = _db.HowCanAcess.Where(s => s.employeeID == ss.id).FirstOrDefault();



                if (_allowAll.AccessAll == true)
                {
                    model.Empx = _db.Employee.ToList();


                    return(View("index", model));
                }
                else if (_allowAll.Employee == true)
                {
                    model.Empx = _db.Employee.ToList();


                    return(View("index", model));
                }
            }
            return(RedirectToAction("HavntAccess", "Employees"));
        }
Exemplo n.º 3
0
        public ActionResult profile()
        {
            if (Session["empName"] != null)
            {
                string item = Session["empName"].ToString();

                var model = new EmpOfficeJob();
                model.Empx    = _db.Employee.Where(s => s.employeeName == item);
                model.JobX    = _db.Jobs.ToList();
                model.OfficeX = _db.Offices.ToList();
                model.EmpY    = _db.Employee.Where(p => p.employeeName == item).FirstOrDefault();
                if (model == null)
                {
                    return(View("HavntAccess"));
                }
                return(View(model));
            }
            return(RedirectToAction("HavntAccess", "Employees"));
        }