コード例 #1
0
        public IActionResult Find(TKey id)
        {
            var entity = _service.Find <TEntity, TKey>(id);

            if (entity == null)
            {
                return(BadRequest(new Error()
                {
                    Message = "Invalid Id ..."
                }));
            }
            return(_GetEntityResult(entity));
        }
コード例 #2
0
 // Method which receive deleteType (logical or physical)
 // and [entityKey OR entity] to be deleted
 // if entityKey was given then get the entity by its key
 // Then call the appropriate function from the BaseService class to execute operation
 public async Task Delete(string deleteType, TKey key, TEntity entity)
 {
     _clientMethod = "Deleted";
     if (deleteType == null)
     {
         await Clients.All.SendAsync(_clientMethod, new Response <String>() { Error = "Can't identify The type of the Delete operation ..." });
     }
     else if (key == null && entity == null)
     {
         await Clients.All.SendAsync(_clientMethod, new Response <String>() { Error = "Must supply either key OR entity ..." });
     }
     else if (key != null)
     {
         entity = _service.Find <TEntity, TKey>(key);
     }
     // if entity that comes from DB is null
     if (entity == null)
     {
         await Clients.All.SendAsync(_clientMethod, new Response <String>() { Error = "Item doesn't exist ..." });
     }
     await DoDelete(deleteType, entity);
 }