Ejemplo n.º 1
0
 public override async Task <DeleteIdiomReply> DeleteIdiom(DeleteIdiomRequest request, ServerCallContext context)
 {
     if (!await _idioms.DeleteIdiom(request.IdiomId))
     {
         throw new RpcException(new Status(StatusCode.NotFound, "Idiom was not found"));
     }
     return(new DeleteIdiomReply {
         Result = "Idiom removed"
     });
 }
Ejemplo n.º 2
0
        public async Task <ActionResult <IdiomVM> > DeleteIdiom(int id)
        {
            try
            {
                var idiomToDelete = await idiomRepository.GetIdiom(id);

                if (idiomToDelete == null)
                {
                    return(NotFound($"Idiom with Id = {id} not found"));
                }

                return(await idiomRepository.DeleteIdiom(id));
            }
            catch (DbUpdateException Ex)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError,
                                  Ex.InnerException.Message));
            }
        }