Exemplo n.º 1
0
 public async Task <ActionResult <Leaders> > Post(Leaders leader)
 {
     try
     {
         repository.Add(leader);
         if (await repository.SaveChangesAsync())
         {
             return(Created("", leader));
         }
     }
     catch (Exception e)
     {
         return(this.StatusCode(StatusCodes.Status500InternalServerError, "Post Leader Failure" + e));
     }
     return(BadRequest());
 }
Exemplo n.º 2
0
 public async Task <ActionResult <Dishes> > Post(Comments comment)
 {
     try
     {
         repository.Add(comment);
         if (await repository.SaveChangesAsync())
         {
             return(Created("", comment));
         }
     }
     catch (Exception e)
     {
         return(this.StatusCode(StatusCodes.Status500InternalServerError, "Post Comment Failure" + e));
     }
     return(BadRequest());
 }
Exemplo n.º 3
0
        public async Task <IActionResult> Delete(int id)
        {
            try
            {
                var selectedDish = await repository.GetDishAsync(id);

                if (selectedDish == null)
                {
                    return(NotFound("Dish not found to delete"));
                }

                repository.Delete(selectedDish);
                if (await repository.SaveChangesAsync())
                {
                    return(Ok());
                }
            }
            catch (Exception e)
            {
                return(this.StatusCode(StatusCodes.Status500InternalServerError, "Delete Dish Failure" + e));
            }
            return(BadRequest());
        }