public ActionResult Delete(int id) { try { policyRepository.Delete(id); return(Json(new { IsSuccess = true, Message = "Xóa thành công" }, JsonRequestBehavior.AllowGet)); } catch (Exception) { return(Json(new { IsSuccess = false, Message = "Xóa thất bại" }, JsonRequestBehavior.AllowGet)); } }
public async Task <IActionResult> DeletePolicy([FromRoute] int id) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var policy = _policyRepository.GetPolicy(id); if (policy == null) { return(NotFound()); } _policyRepository.Delete(id); return(Ok(policy)); }
public ResponseEntityVM Delete(object id) { try { var policy = _repository.Find(id); if (policy == null) { return new ResponseEntityVM() { StatusCode = System.Net.HttpStatusCode.NotFound } } ; var validatePolicyNotInUseResult = ValidatePolicyNotInUse(policy); if (validatePolicyNotInUseResult.StatusCode == System.Net.HttpStatusCode.OK) { _repository.Delete(policy); _repository.SaveChanges(); return(new ResponseEntityVM() { StatusCode = System.Net.HttpStatusCode.NoContent }); } return(validatePolicyNotInUseResult); } catch (Exception ex) { return(new ResponseEntityVM() { StatusCode = System.Net.HttpStatusCode.InternalServerError, Message = $"There was an error deleting the policy: {ex.Message}" }); } }
public async Task <bool> Execute(string policyId) { _umaServerEventSource.StartToRemoveAuthorizationPolicy(policyId); if (string.IsNullOrWhiteSpace(policyId)) { throw new ArgumentNullException(nameof(policyId)); } var policy = await _repositoryExceptionHelper.HandleException( string.Format(ErrorDescriptions.TheAuthorizationPolicyCannotBeRetrieved, policyId), () => _policyRepository.Get(policyId)); if (policy == null) { return(false); } await _repositoryExceptionHelper.HandleException( string.Format(ErrorDescriptions.TheAuthorizationPolicyCannotBeUpdated, policyId), () => _policyRepository.Delete(policyId)); _umaServerEventSource.FinishToRemoveAuthorizationPolicy(policyId); return(true); }
// DELETE api/values/5 public void Delete(int id) { policyRepository.Delete(id); }
public async Task <bool> Delete(int id) { return(await _policyRepository.Delete(id)); }
public void Delete(PolicyEntity policyEntity) { _policyRepository.Delete(policyEntity); }
/// <summary> /// The Delete. /// </summary> /// <param name="policyId">The policyId<see cref="long"/>.</param> public void Delete(long policyId) { _policyRepository.Delete(policyId); }
// POST: Policies/Delete/5 public ActionResult Delete(int id) { policyRepository.Delete(id); return(RedirectToAction(nameof(Index))); }
public async Task <bool> Execute(UpdateResourcePermissionsParameter updateResourcePermissionsParameter) { if (updateResourcePermissionsParameter == null) { throw new ArgumentNullException(nameof(updateResourcePermissionsParameter)); } if (string.IsNullOrWhiteSpace(updateResourcePermissionsParameter.ResourceId)) { throw new BaseUmaException(Errors.ErrorCodes.InvalidRequestCode, Errors.ErrorDescriptions.TheResourceIdMustBeSpecified); } var resource = await _resourceSetRepository.Get(updateResourcePermissionsParameter.ResourceId).ConfigureAwait(false); if (resource == null) { throw new UmaResourceNotFoundException(); } if (updateResourcePermissionsParameter.Subject != resource.Owner) { throw new UmaNotAuthorizedException(); } var policiesToBeUpdated = resource.AuthPolicies.ToList(); var policiesToBeRemoved = new List <string>(); var length = policiesToBeUpdated.Count(); for (int i = length - 1; i >= 0; i--) { var policy = policiesToBeUpdated.ElementAt(i); var policyParameter = updateResourcePermissionsParameter.PolicyIds.FirstOrDefault(p => p == policy.Id); if (policyParameter == null) { policiesToBeUpdated.Remove(policy); policiesToBeRemoved.Add(policy.Id); } } using (var transaction = new CommittableTransaction(new TransactionOptions { IsolationLevel = IsolationLevel.ReadCommitted })) { try { var operations = new List <Task <bool> >(); foreach (var policyId in policiesToBeRemoved) { operations.Add(_policyRepository.Delete(policyId)); } await Task.WhenAll(operations).ConfigureAwait(false); transaction.Commit(); return(true); } catch { transaction.Rollback(); throw; } } }
public bool DeletePolicy(int policyId) { return(_policyRepository.Delete(policyId)); }
public bool DeletePolicy(Guid id) { _PolicyRepo.Delete(id); return(_unitOfWork.Commit()); }