public async Task <IActionResult> Post([FromBody] Category value)
        {
            try
            {
                if (await _usersManager.CheckUserAuthentication(Request))
                {
                    if (value != null)
                    {
                        Category category = await _categoriesManager.AddCategory(value);

                        return(Ok(category));
                    }
                    else
                    {
                        return(NoContent());
                    }
                }
                else
                {
                    return(Unauthorized());
                }
            }
            catch (CouldNotPerformOperationException ex)
            {
                return(BadRequest(ex));
            }
        }
Exemplo n.º 2
0
 public async Task <IActionResult> Get()
 {
     try
     {
         if (await _usersManager.CheckUserAuthentication(Request))
         {
             return(Ok(new string[] { "value1", "value2" }));
         }
         else
         {
             return(Unauthorized());
         }
     }
     catch (NotAuthenticatedException)
     {
         return(Unauthorized());
     }
     catch (TokenExpiredException)
     {
         return(Unauthorized());
     }
 }