public async Task <IActionResult> Delete(int?id)
        {
            ResponseDTO oResponse = new();

            if (id == null)
            {
                oResponse.Message = "Se debe indicar el identificador del recurso.";

                return(BadRequest(oResponse));
            }

            ApplicationUserViewModel oUser = await _appUserService.GetByIdAsync(id.Value);

            if (oUser != null)
            {
                string fileName = oUser.ImageName;

                if (await _appUserService.DeleteAsync(id.Value))
                {
                    oResponse.Message = "El recurso se ha eliminado exitosamente!";
                    oResponse.Success = true;

                    try
                    {
                        await _blobService.DeleteBlobAsync(fileName);
                    }
                    catch (Exception ex)
                    {
                        oResponse.Message = "El recurso se ha eliminado exitosamente, aunque tuvimos un problema al intentar eliminar la imagen del sistema.";
                    }

                    return(Ok(oResponse));
                }
                else
                {
                    oResponse.Message = "Hubo un problema, no se pudo eliminar el registro.";

                    return(StatusCode(StatusCodes.Status500InternalServerError, oResponse));
                }
            }
            else
            {
                oResponse.Message = "No se ha encontrado el recurso solicitado.";

                return(NotFound(oResponse));
            }
        }
        public async Task <IActionResult> DeleteAsync(Guid id)
        {
            try
            {
                await applicationUserService.DeleteAsync(id);

                return(Ok());
            }
            catch (EntityNotFoundException <ApplicationUser> )
            {
                return(NoContent());
            }
            catch (Exception)
            {
                return(BadRequest());
            }
        }
        public async Task <IActionResult> DeleteUserAsync(string id)
        {
            await applicationUserService.DeleteAsync(id);

            return(RedirectToAction("UsersList", "Account"));
        }
示例#4
0
        public async Task <IActionResult> DeleteConfirmed(TPrimaryKey id)
        {
            await _applicationUserService.DeleteAsync(id);

            return(RedirectToAction("Index"));
        }