protected override async Task <Applications> Insert(Applications item) { try { APPLICATIONS data = MapToEntity(item); data.APPLICATIONID = GenerateId(); data.APPLICAITONSECRET = GenerateId(); _ctx.APPLICATIONS.Add(data); _ctx.Entry(data).State = System.Data.Entity.EntityState.Added; if (await _ctx.SaveChangesAsync() <= 0) { var error = new ValidationFailure("Application", string.Format(ValidationErrorMessage.GenericDBSaveError, "Application")); item.Validation.Errors.Add(error); _logger.Log("FATAL", "Save Application", item, error.ErrorMessage); item.Validation.Errors.Add(error); return(item); } _logger.Log("FATAL", "Add Application", item, "Successful."); return(await GetByNameAsync(data.APPLICATIONNAME)); } catch (Exception ex) { item.Validation = CommonFn.CreateValidationError(ValidationErrorMessage.GenericDBDeleteError, "PERMISSIONS"); _logger.Log("INFO", "Save Application", item, ex.Message); return(item); } }
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); } }
protected override async Task <Permissionsofrole> Update(Permissionsofrole item) { PERMISSIONSOFROLE data = MapToEntity(item); _ctx.Entry(data).State = EntityState.Modified; if (await _ctx.SaveChangesAsync() <= 0) { item.Validation = CommonFn.CreateValidationError(ValidationErrorMessage.GenericDBSaveError, "Permissionsofrole"); } return(item); }
protected override async Task <IdentityRefreshToken> Update(IdentityRefreshToken item) { REFRESHTOKEN data = MapToEntity(item); _ctx.Entry(data).State = EntityState.Modified; if (await _ctx.SaveChangesAsync() <= 0) { item.Validation = CommonFn.CreateValidationError(ValidationErrorMessage.GenericDBSaveError, "Refreshtoken"); } return(item); }
protected override async Task <IdentityClient> Update(IdentityClient item) { APPLICATIONS data = MapToEntity(item); _ctx.Entry(data).State = EntityState.Modified; if (await _ctx.SaveChangesAsync() <= 0) { item.Validation = CommonFn.CreateValidationError(ValidationErrorMessage.GenericDBSaveError, "Applications"); } return(item); }
protected override async Task <IdentityLogin> Update(IdentityLogin item) { USERLOGIN data = MapToEntity(item); _ctx.Entry(data).State = EntityState.Modified; if (await _ctx.SaveChangesAsync() <= 0) { item.Validation = CommonFn.CreateValidationError(ValidationErrorMessage.GenericDBSaveError, "Userlogin"); } return(item); }
protected override async Task <IdentityProfile> Insert(IdentityProfile item) { item.Useraccountid = GenerateId(); USERPROFILE data = MapToEntity(item); _ctx.Entry(data).State = EntityState.Added; if (await _ctx.SaveChangesAsync() <= 0) { item.Validation = CommonFn.CreateValidationError(ValidationErrorMessage.GenericDBSaveError, "Userprofile"); } return(item); }
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); }
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); }
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); }