Skip to content

Commit

Permalink
exibindo logs completos da CategoryController
Browse files Browse the repository at this point in the history
  • Loading branch information
DiegoTelis committed Feb 20, 2024
1 parent f2dc398 commit 64a4297
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions Controllers/CategoryController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
namespace Blog.Controllers
{
[ApiController]
public class CategoryController: ControllerBase
public class CategoryController : ControllerBase
{
[HttpGet("v1/categories")]
public async Task<IActionResult> GetAsync(
Expand All @@ -25,14 +25,14 @@ public async Task<IActionResult> GetAsync(
entry.AbsoluteExpirationRelativeToNow = TimeSpan.FromHours(1);
return GetCategories(context);
});



return Ok(new ResultVM<List<Category>>(categories));
}
catch
catch (Exception ex)
{
return StatusCode(500, new ResultVM<List<Category>>("05x06 - Falha interna no Servidor"));
return StatusCode(500, new ResultVM<List<Category>>("05x06 - Falha interna no Servidor \n" + ex.Message + "\n" + ex.ToString));
}
}

Expand All @@ -57,13 +57,13 @@ public async Task<IActionResult> GetByIdAsync(

return Ok(new ResultVM<Category>(category));
}
catch(DbUpdateException ex)
catch (DbUpdateException ex)
{
return StatusCode(500, new ResultVM<Category>("05x07 - Não foi possivel incluir categoria"));
}
catch (Exception ex)
catch (Exception ex)
{
return StatusCode(500, new ResultVM<Category>( "05x08 - Falha interna no Servidor"));
return StatusCode(500, new ResultVM<Category>("05x08 - Falha interna no Servidor"));
}
}

Expand All @@ -77,25 +77,25 @@ public async Task<IActionResult> PostAsync(

try
{
var category = new Category
{
Id=0,
Name=model.Name,
Slug=model.Slug.ToLower()
var category = new Category
{
Id = 0,
Name = model.Name,
Slug = model.Slug.ToLower()
};
await context.Categories.AddAsync(category);
await context.SaveChangesAsync();

return Created($"v1/categories/{category.Id}", new ResultVM<Category>(category));
}
catch(DbUpdateException ex)
catch (DbUpdateException ex)
{
return StatusCode(500, new ResultVM<Category>("05x09 - Não foi possivel incluir categoria"));
}
catch

catch (Exception ex)
{
return StatusCode(500, new ResultVM<Category>("05x10 - Falha interna no Servidor"));
return StatusCode(500, new ResultVM<Category>("05x10 - Falha interna no Servidor\n" + ex.Message + "\n" + ex.ToString));
}


Expand Down Expand Up @@ -126,7 +126,7 @@ public async Task<IActionResult> PutAsync(
return StatusCode(500, new ResultVM<Category>("05x12 - Não foi possivel incluir categoria"));
}

catch
catch
{
return StatusCode(500, new ResultVM<Category>("05x13 - Falha interna no Servidor"));
}
Expand Down Expand Up @@ -154,7 +154,7 @@ public async Task<IActionResult> DeleteAsync(
return StatusCode(500, new ResultVM<Category>("05x14 - Não foi possivel incluir categoria"));
}

catch
catch
{
return StatusCode(500, new ResultVM<Category>("05x15 - Falha interna no Servidor"));
}
Expand Down

0 comments on commit 64a4297

Please sign in to comment.