Пример #1
0
        public ActionResult DeleteConfirmed(int id)
        {
            Organisation organisation = _organisationService.GetById(id);

            _organisationService.Delete(organisation.ID);
            return(RedirectToAction("Index"));
        }
Пример #2
0
        public IActionResult Delete(string id)
        {
            _logger.LogInformation($"Trying to delete organisation record {id}");
            try
            {
                var exists = _organisationsService.Get(id);

                OrganisationResponse.Success = false;
                OrganisationResponse.Data    = new List <Organisation>();

                if (exists == null)
                {
                    OrganisationResponse.Message = "Volunteer record not found. Cannot delete.";
                    return(NotFound(new[] { OrganisationResponse }));
                }

                bool volunteerRemoved = _organisationsService.Delete(id);

                if (!volunteerRemoved)
                {
                    OrganisationResponse.Message = "Volunteer record not deleted";
                    return(BadRequest(new[] { OrganisationResponse }));
                }

                OrganisationResponse.Success = true;
                OrganisationResponse.Message = $"Volunteer record with id {id} deleted.";
                return(Ok(new[] { OrganisationResponse }));
            }
            catch (MongoException ex)
            {
                _logger.LogDebug($"Error removing from DB: {ex.Message}");
            }
            catch (Exception ex)
            {
                _logger.LogDebug($"Error: {ex.Message}");
            }
            _logger.LogInformation("Error: delete request cannot be handled, bad request.");
            return(BadRequest());
        }