public IActionResult Delete(int id) { try { var entity = _service.Resources.Id(id).FirstOrDefault(); if (entity == null) { return(NotFound(AppResult.NotFound())); } var validationData = _service.ValidateDeleteResource(User, entity); if (!validationData.IsValid) { return(BadRequest(AppResult.FailValidation(data: validationData))); } _service.DeleteResource(entity); context.SaveChanges(); // must be in transaction var ev = _ev_service.DeleteResource(entity, User); context.SaveChanges(); return(NoContent()); } catch (DbUpdateException e) { _logger.Error(e); return(BadRequest(AppResult.DependencyDeleteFail())); } }
public IActionResult DeleteResource([FromQuery] int resourceId) { try { _resourceService.DeleteResource(resourceId); return(Ok()); } catch (Exception ex) { return(BadRequest(ex.Message)); } }
public async Task <IActionResult> Delete(int resourceId) { var output = await _service.DeleteResource(resourceId); if (output.IsErrorOccured) { return(BadRequest(output)); } else { return(Ok(output)); } }
public ActionResult Delete(Guid resourceId, FormCollection collection) { try { service.DeleteResource(resourceId); return(RedirectToAction("Index")); } catch { return(View()); } }
public ActionResult Delete(int?id) { if (id.HasValue) { var resource = resourceService.GetResource(id.Value); if (resource != null) { resourceService.DeleteResource(resource); resourceService.SaveResource(); return(RedirectToAction("Index")); } } return(RedirectToAction("Index")); }
public ActionResult Delete(int id) { var resource = _resourceService.GetResourceBy(id); if (!_securityService.CanDelete(resource)) { return(RedirectToAction("ForbiddenError", "Home")); } try { _resourceService.DeleteResource(id); _resourceService.SaveChanges(); } catch (DbUpdateException e) { return(RedirectToAction("ConflictError", "Home", new { message = ExceptionHelper.RollToInnerException(e).Message })); } return(RedirectToAction("GetDataTable")); }
public async Task <IActionResult> DeleteResource( [FromRoute] long tenantId, [FromRoute] string key) { if (!isOperationAuthorized(tenantId)) { return(Unauthorized()); } var resource = await _resourceService.GetResource(tenantId, key); if (resource == null) { return(NotFound()); } await _resourceService.DeleteResource(resource); return(Ok(resource)); }
private async void DeleteButton_Click(object sender, RoutedEventArgs e) { MessageBoxResult result = MessageBox.Show( "Ви не зможете відмінити цю дію. Ви впевнені, що хочете видалити ресурс?", "Підтвердіть операцію", MessageBoxButton.YesNoCancel, MessageBoxImage.Asterisk); if (result != MessageBoxResult.Yes) { return; } RegistryCommon.Instance.MainProgressBar.Text = StatusBarState.Deleting; DeleteButton.IsEnabled = false; await _resourceService.DeleteFromBlob(_selectedResource.Url); await _resourceService.DeleteResource(_selectedResource.Id); RegistryCommon.Instance.MainProgressBar.Text = StatusBarState.Ready; RegistryCommon.Instance.MainGrid.OpenUserControlWithSignOut(new Resources()); }
private BaseActionResult Delete(ResourceModel model) { BaseActionResult result = new BaseActionResult(); try { if (!model.DeleteModalityType)//delete modality { if (resourceService.DeleteResource(model)) { result.Result = true; } else { result.Result = false; } } else//delete modality type { if (resourceService.DeleteModalityType(model)) { result.Result = true; } else { result.Result = false; } } } catch (Exception ex) { result.Result = false; result.ReturnMessage = ex.Message; } return(result); }
public IHttpActionResult DeleteResource(int id) { resourceService.DeleteResource(id); return(Ok()); }
public IActionResult DeleteResourceAsync([FromQuery] Uri pidUri) { var result = _resourceService.DeleteResource(pidUri); return(Ok(result)); }
public async Task <IActionResult> DeleteResource(Guid resourceId) { await resourceService.DeleteResource(resourceId); return(new OkResult()); }
public async Task<IActionResult> DeleteResource(int id) { var result = await _resourceService.DeleteResource(id); return result.ToJsonResult(); }
public async Task <IActionResult> DeleteResourceAsync([FromQuery] Uri pidUri, [FromQuery] string requester) { var result = await _resourceService.DeleteResource(pidUri, requester); return(Ok(result)); }
public async Task DeleteResource(string guid) { await _resourceService.DeleteResource(guid); }