Exemple #1
0
        public ActionResult Index()
        {
            if (ac.GetUser("administrator") == null)
            {
                return(RedirectToAction("Index", "Login"));
            }
            var dbList = db.User.ToList();
            IEnumerable <UserVM> list = mapper.Map <IEnumerable <UserVM> >(dbList);

            return(View("Index", list));
        }
Exemple #2
0
        // GET: Corrigir/Corrigir/5
        public ActionResult Corrigir(int?id)
        {
            AccessControl ac = new AccessControl();

            if (ac.GetUser("Administrator") == null)
            {
                return(RedirectToAction("Index", "Login"));
            }

            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Question e = db.Question.Find(id);

            if (e == null)
            {
                ModelState.AddModelError("error", "Registro não encontrado");
                return(RedirectToAction("Index"));
            }
            if (e != null)
            {
                IEnumerable <Grade> dbList = GetGrade(e.Id);
                ViewBag.Grade = new SelectList(dbList, "Id", "Grade1");

                int QuestionId = e.Id;
                return(ShowView(QuestionId, false));
            }

            ModelState.AddModelError("error", "Erro inesperado. Tente novamente");
            return(RedirectToAction("Index"));
        }
        public IHttpActionResult Me()
        {
            var token = ActionContext.Request.Headers.Authorization.Parameter;

            AccessControl ac = AccessControl.find(db, token);

            if (ac == null)
            {
                return(NotFound());
            }

            User user = ac.GetUser(db);

            if (user == null)
            {
                return(NotFound());
            }

            return(Ok(
                       new
            {
                id_user = user.ID_USER,
                email = user.EMAIL,
                name = user.NAME,
                permission = user.PERMISSION,
                id_plan = user.ID_PLAN,
                document = user.DOCUMENT
            }
                       ));
        }
Exemple #4
0
        public ActionResult Corrigir(ImageCandidate ic)
        {
            AccessControl ac = new AccessControl();

            if (ac.GetUser("Administrator") == null)
            {
                return(RedirectToAction("Index", "Login"));
            }

            if (ModelState.IsValid)
            {
                QuestionResult e = new QuestionResult();
                e.CandidateId = ic.CandidateId;
                e.QuestionId  = ic.QuestiontId;
                e.Grade       = Convert.ToDecimal(Request.Form["Grade"].ToString());
                db.QuestionResult.Add(e);
                //db.SaveChanges();

                ic.InUse           = false;
                db.Entry(ic).State = EntityState.Modified;
                db.SaveChanges();

                IEnumerable <Grade> dbList = GetGrade(ic.QuestiontId);
                ViewBag.Grade = new SelectList(dbList, "Id", "Grade1");

                int QuestionId = ic.QuestiontId;
                return(ShowView(QuestionId, true));
            }

            ModelState.AddModelError("error", "Erro inesperado. Tente novamente");
            return(RedirectToAction("Index"));
        }
Exemple #5
0
        public ActionResult ChangePassword()
        {
            if (ac.GetUser("administrator") == null)
            {
                return(RedirectToAction("Index", "Login"));
            }

            MembershipUser       user       = ac.GetUser();
            CustomMembershipUser customUser = (CustomMembershipUser)user;

            LoginChangePassword vm = new LoginChangePassword();

            vm.UserId = customUser != null ? customUser.Id : 0;
            vm.CPF    = customUser != null ? customUser.CPF : "";
            return(View(vm));
        }
        public void Validate()
        {
            AccessControl ac = new AccessControl();

            if (ac.GetUser("administrator") == null)
            {
                RedirectToAction("Index", "Login");
            }
        }
        // GET: Question
        public ActionResult Index()
        {
            if (ac.GetUser("administrator") == null)
            {
                return(RedirectToAction("Index", "Login"));
            }
            IEnumerable <Question>   dbList = db.Question;
            IEnumerable <QuestionVM> list   = mapper.Map <IEnumerable <QuestionVM> >(dbList);

            return(View(list));
        }
        // GET: QuestionGrade
        public ActionResult Index()
        {
            if (ac.GetUser("administrator") == null)
            {
                return(RedirectToAction("Index", "Login"));
            }

            IEnumerable <Question> dbListQuestion = db.Question;

            ViewBag.Question = new SelectList(dbListQuestion, "Id", "Number");

            IEnumerable <Grade> dbListGrade = db.Grade;

            ViewBag.Grade = new SelectList(dbListGrade, "Id", "Grade1");

            IEnumerable <QuestionGrade>   dbList = db.QuestionGrade;
            IEnumerable <QuestionGradeVM> list   = mapper.Map <IEnumerable <QuestionGradeVM> >(dbList);

            return(View(list));
        }
        public IHttpActionResult Login(User user)
        {
            AccessControl ac = user.doLogin(db);

            if (ac == null)
            {
                return(BadRequest("Email ou senha inválido"));
            }
            user = ac.GetUser(db);
            return(Created("",
                           new
            {
                token = ac.TOKEN,
                user = new
                {
                    id_user = user.ID_USER,
                    email = user.EMAIL,
                    name = user.NAME,
                    permission = user.PERMISSION
                }
            }
                           ));
        }