예제 #1
0
        public async Task <IActionResult> DisableOrEnableUser(int id)
        {
            Response oR = new Response();

            try
            {
                if (await _service.ExistsId(id))
                {
                    oR.Status  = StatusCodes.Status404NotFound;
                    oR.Message = Messages.ResourceNotFound;

                    return(NotFound(oR));
                }

                if (!await _service.DisableOrEnableUser(id))
                {
                    oR.Status  = StatusCodes.Status500InternalServerError;
                    oR.Message = Messages.InternalServerError;

                    return(StatusCode(StatusCodes.Status500InternalServerError, oR));
                }

                oR.Status = StatusCodes.Status204NoContent;

                return(NoContent());
            }
            catch (Exception ex)
            {
                oR.Status  = StatusCodes.Status500InternalServerError;
                oR.Message = Messages.InternalServerError;

                return(StatusCode(StatusCodes.Status500InternalServerError, oR));
            }
        }