public IActionResult Delete(int id)
        {
            var admin = _service.GetIncludedSingle(a => a.Id == id);

            _service.Delete(admin);

            return(StatusCode(204));
        }
Example #2
0
        public IHttpActionResult Delete(int id)
        {
            var result = _adminService.Delete(id);

            if (result == null)
            {
                return(NotFound());
            }

            return(Ok(result));
        }
Example #3
0
 public ActionResult Delete(string id) // <-- For the Administrator entity, the id is the username
 {
     try
     {
         _administratorService.Delete(id);
         return(new EmptyResult());
     }
     catch (Exception ex)
     {
         Response.StatusCode = 500;
         return(Json(ex.ToString()));
     }
 }
 public async Task <ActionResult> Delete(Guid id)
 {
     if (!ModelState.IsValid)
     {
         return(BadRequest(ModelState));
     }
     try
     {
         return(Ok(await _service.Delete(id)));
     }
     catch (ArgumentException e)
     {
         return(StatusCode((int)HttpStatusCode.InternalServerError, e.Message));
     }
 }
        public async Task <ActionResult <AdministratorDetail_AdministratorDTO> > Delete([FromBody] AdministratorDetail_AdministratorDTO AdministratorDetail_AdministratorDTO)
        {
            if (!ModelState.IsValid)
            {
                throw new MessageException(ModelState);
            }

            Administrator Administrator = ConvertDTOToEntity(AdministratorDetail_AdministratorDTO);

            Administrator = await AdministratorService.Delete(Administrator);

            AdministratorDetail_AdministratorDTO = new AdministratorDetail_AdministratorDTO(Administrator);
            if (Administrator.IsValidated)
            {
                return(AdministratorDetail_AdministratorDTO);
            }
            else
            {
                return(BadRequest(AdministratorDetail_AdministratorDTO));
            }
        }
        public IActionResult Delete(string id)
        {
            var user  = _iAdministratorService.GetById(id);
            var count = 1;

            if (user == null)
            {
                throw new Exception("该用户不存在");
            }
            try
            {
                // save
                _iAdministratorService.Delete(id);
                return(Output(new DeleteOrUpdateResponse
                {
                    id = id
                }, count));
            }
            catch (AppException ex)
            {
                // return error message if there was an exception
                return(BadRequest(new { message = ex.Message }));
            }
        }