コード例 #1
0
        public async Task <ActionResult <ApiResponse> > GetEntityType(int id)
        {
            try
            {
                AppEntityType type = await _repo.GetEntityTypeByIdAsync(id);

                if (type == null)
                {
                    return(NotFound(new ApiResponse(StatusCodes.Status404NotFound, "Erro. Tipo de entidade não encontrado.")));
                }

                AppEntityTypeModel typeModel = new AppEntityTypeModel()
                {
                    Id   = type.Id,
                    Name = type.Name
                };

                return(Ok(new ApiResponse <AppEntityTypeModel>(StatusCodes.Status200OK, "OK", typeModel)));
            }
            catch (Exception)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError,
                                  new ApiResponse(StatusCodes.Status500InternalServerError, "Erro inesperado. Tente mais tarde.")));
            }
        }
コード例 #2
0
 public void RemoveEntityType(AppEntityType typeToRemove)
 {
     _db.AppEntityTypes.Remove(typeToRemove);
 }
コード例 #3
0
 public void AddEntityType(AppEntityType newType)
 {
     _db.AppEntityTypes.Add(newType);
 }