Exemplo n.º 1
0
        public async Task <Usersinrole> DeleteAsync(Usersinrole item)
        {
            try
            {
                var validator = new UserRoleDeleteValidator(_ctx);
                item.Validation = validator.Validate(item);
                if (!item.Validation.IsValid)
                {
                    return(await Task.FromResult(item));
                }

                USERSINROLE data = MapToEntity(item);
                _ctx.Entry(data).State = EntityState.Deleted;
                var error = new ValidationFailure("Role", string.Format(ValidationErrorMessage.GenericDBDeleteError, "Role"));
                item.Validation.Errors.Add(error);
                await _ctx.SaveChangesAsync();

                _logger.Log("FATAL", "Delete User in Role", item, error.ErrorMessage);


                return(item);
            }

            catch (Exception ex)
            {
                item.Validation = CommonFn.CreateValidationError(ValidationErrorMessage.GenericDBDeleteError, "Usersinrole");
                _logger.Log("INFO", "Delete User in Role", item, "Successful.");
                return(item);
            }
        }
Exemplo n.º 2
0
        public async Task <IdentityRefreshToken> DeleteAsync(IdentityRefreshToken item)
        {
            REFRESHTOKEN data = MapToEntity(item);

            _ctx.Entry(data).State = EntityState.Deleted;
            if (await _ctx.SaveChangesAsync() <= 0)
            {
                item.Validation = CommonFn.CreateValidationError(ValidationErrorMessage.GenericDBDeleteError, "Refreshtoken");
            }
            if (item.Validation == null)
            {
                item.Validation = new ValidationResult();
            }
            return(item);
        }
Exemplo n.º 3
0
        public async Task <IdentityClient> DeleteAsync(IdentityClient item)
        {
            APPLICATIONS data = MapToEntity(item);

            _ctx.Entry(data).State = EntityState.Deleted;
            if (await _ctx.SaveChangesAsync() <= 0)
            {
                item.Validation = CommonFn.CreateValidationError(ValidationErrorMessage.GenericDBDeleteError, "Applications");
            }
            if (item.Validation == null)
            {
                item.Validation = new ValidationResult();
            }
            return(item);
        }
Exemplo n.º 4
0
        public async Task <IdentityLogin> DeleteAsync(IdentityLogin item)
        {
            USERLOGIN data = MapToEntity(item);

            _ctx.Entry(data).State = EntityState.Deleted;
            if (await _ctx.SaveChangesAsync() <= 0)
            {
                item.Validation = CommonFn.CreateValidationError(ValidationErrorMessage.GenericDBDeleteError, "Userlogin");
            }
            if (item.Validation == null)
            {
                item.Validation = new ValidationResult();
            }
            return(item);
        }
Exemplo n.º 5
0
        public async Task <Users> DeleteAsync(Users item)
        {
            var data = await _ctx.USERS.FirstOrDefaultAsync(x => x.USERID == item.Userid);

            data.ISDELETED         = true;
            _ctx.Entry(data).State = EntityState.Modified;
            if (await _ctx.SaveChangesAsync() <= 0)
            {
                var error = new ValidationFailure("User", string.Format(ValidationErrorMessage.GenericDBDeleteError, "User"));
                item.Validation.Errors.Add(error);
                _logger.Log("FATAL", "Delete User", item, error.ErrorMessage);
                return(await Task.FromResult <Users>(item));
            }
            _logger.Log("INFO", "Delete User", item, "Successful.");
            return(await Task.FromResult <Users>(MapToDTO(data)));
        }
Exemplo n.º 6
0
        private bool IsAuthenticationSuccessful(USERS dbUser, string password)
        {
            var IsSuccessful = Crypto.VerifyHashedPassword(dbUser.PASSWORD, password);

            // TODO: Replace DateTime.Now with Database Time
            DateTime now = DateTime.Now;

            if (IsSuccessful)
            {
                dbUser.PASSWORDFAILCOUNT = 0;
                dbUser.DATELASTLOGIN     = now;
            }
            else
            {
                dbUser.PASSWORDFAILCOUNT++;
                if (dbUser.PASSWORDFAILCOUNT >= MaxPasswordFail)
                {
                    dbUser.ISLOCKEDOUT     = true;
                    dbUser.DATELASTLOCKOUT = now;
                }
            }
            _ctx.USERS.Attach(dbUser);
            _ctx.Entry(dbUser).State = EntityState.Modified;
            IsSuccessful             = _ctx.SaveChanges() > 0 && IsSuccessful;
            return(IsSuccessful);
        }
Exemplo n.º 7
0
        public async Task <Permissionsofrole> DeleteAsync(Permissionsofrole item)
        {
            var validator = new RolePermissionDeleteValidator(_ctx);

            item.Validation = validator.Validate(item);
            if (!item.Validation.IsValid)
            {
                return(await Task.FromResult(item));
            }
            PERMISSIONSOFROLE data = MapToEntity(item);

            _ctx.Entry(data).State = EntityState.Deleted;

            if (await _ctx.SaveChangesAsync() <= 0)
            {
                var error = new ValidationFailure("PermissionofRole", string.Format(ValidationErrorMessage.GenericDBDeleteError, "PermissionofRole"));
                item.Validation.Errors.Add(error);
                _logger.Log("FATAL", "Delete Permission of Role", item, error.ErrorMessage);
                return(item);
            }
            _logger.Log("INFO", "Delete Permission of Role", item, "Successful.");
            return(item);
        }