コード例 #1
0
        public AppUserAuth ValidateUser(AppUser user)
        {
            AppUserAuth ret      = new AppUserAuth();
            AppUser     authUser = null;

            using (var db = new ComVotDbContext())
            {
                authUser = db.Users.Where(
                    u => u.UserName.ToLower() == user.UserName.ToLower() &&
                    u.Password == user.Password).FirstOrDefault();
            }

            if (authUser != null)
            {
                ret = BuildUserAuthObject(authUser);
            }

            return(ret);
        }
コード例 #2
0
        protected List <AppUserClaim> GetUserClaims(AppUser authUser)
        {
            List <AppUserClaim> list = new List <AppUserClaim>();

            try
            {
                using (var db = new ComVotDbContext())
                {
                    list = db.Claims.Where(
                        u => u.UserId == authUser.UserId).ToList();
                }
            }
            catch (Exception ex)
            {
                throw new Exception(
                          "Exception trying to retrieve user claims.", ex);
            }

            return(list);
        }
コード例 #3
0
        public IActionResult Get()
        {
            IActionResult           ret  = null;
            List <TipoConstitucion> list = new List <TipoConstitucion>();
            List <Coalicion>        coal = new List <Coalicion>();

            try
            {
                using (var db = new ComVotDbContext())
                {
                    if (db.Constituciones.Count() > 0)
                    {
                        // NOTE: Declare 'list' outside the using to avoid
                        // it being disposed before it is returned.
                        list = db.Constituciones.OrderBy(p => p.Nombre).ToList();
                        // coal = db.Coaliciones.FromSqlRaw("exec sp_listado_coaliciones").ToList();

                        //Console.WriteLine(coal.Select(var ab => new Coalicion() {
                        //}));


                        ret = StatusCode(StatusCodes.Status200OK, list);
                    }
                    else
                    {
                        ret = StatusCode(StatusCodes.Status404NotFound,
                                         "Can't Find Categories");
                    }
                }
            }
            catch (Exception ex)
            {
                ret = HandleException(ex,
                                      "Exception trying to get all Categories");
            }

            return(ret);
        }