Beispiel #1
0
        public async Task <LookupCode> Add(LookupCode courtRoleCode)
        {
            await _db.LookupCode.AddAsync(courtRoleCode);

            await _db.SaveChangesAsync();

            return(courtRoleCode);
        }
Beispiel #2
0
        public async Task <User> UpsertUserFromClaims(ClaimsIdentity claimsIdentity)
        {
            var claims = claimsIdentity.Claims.ToList();
            var id     = Guid.Parse(claims.GetValueByType(ClaimTypes.NameIdentifier));
            var user   = await _db.User.FindAsync(id);

            if (user != null && !user.IsDisabled)
            {
                user.LastLogin = DateTime.Now;
            }
            else if (user == null)
            {
                user = new User
                {
                    Id = id,
                    PreferredUsername = claims.GetValueByType("preferred_username"),
                    IdirId            = Guid.Parse(claims.GetValueByType("idir_userid")),
                    FirstName         = claims.GetValueByType(ClaimTypes.GivenName),
                    LastName          = claims.GetValueByType(ClaimTypes.Name),
                    Email             = claims.GetValueByType(ClaimTypes.Email),
                    IsDisabled        = true
                };
                await _db.User.AddAsync(user);
            }
            await _db.SaveChangesAsync();

            return(user);
        }
Beispiel #3
0
        public async Task <Sheriff> DisableSheriff(Guid id)
        {
            var sheriff = await _db.Sheriff.FindAsync(id);

            if (sheriff == null)
            {
                throw new BusinessLayerException($"Sheriff with the id: {id} could not be found. ");
            }

            sheriff.IsDisabled = true;
            await _db.SaveChangesAsync();

            return(sheriff);
        }