コード例 #1
0
 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()));
     }
 }
コード例 #2
0
        public IActionResult DeleteResource([FromQuery] int resourceId)
        {
            try
            {
                _resourceService.DeleteResource(resourceId);

                return(Ok());
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
コード例 #3
0
        public async Task <IActionResult> Delete(int resourceId)
        {
            var output = await _service.DeleteResource(resourceId);

            if (output.IsErrorOccured)
            {
                return(BadRequest(output));
            }
            else
            {
                return(Ok(output));
            }
        }
コード例 #4
0
        public ActionResult Delete(Guid resourceId, FormCollection collection)
        {
            try
            {
                service.DeleteResource(resourceId);

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
コード例 #5
0
 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"));
 }
コード例 #6
0
        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"));
        }
コード例 #7
0
        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));
        }
コード例 #8
0
        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());
        }
コード例 #9
0
        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);
        }
コード例 #10
0
 public IHttpActionResult DeleteResource(int id)
 {
     resourceService.DeleteResource(id);
     return(Ok());
 }
コード例 #11
0
        public IActionResult DeleteResourceAsync([FromQuery] Uri pidUri)
        {
            var result = _resourceService.DeleteResource(pidUri);

            return(Ok(result));
        }
コード例 #12
0
        public async Task <IActionResult> DeleteResource(Guid resourceId)
        {
            await resourceService.DeleteResource(resourceId);

            return(new OkResult());
        }
コード例 #13
0
        public async Task<IActionResult> DeleteResource(int id)
        {
            var result = await _resourceService.DeleteResource(id);

            return result.ToJsonResult();
        }
コード例 #14
0
        public async Task <IActionResult> DeleteResourceAsync([FromQuery] Uri pidUri, [FromQuery] string requester)
        {
            var result = await _resourceService.DeleteResource(pidUri, requester);

            return(Ok(result));
        }
コード例 #15
0
 public async Task DeleteResource(string guid)
 {
     await _resourceService.DeleteResource(guid);
 }