public async Task <Result <CollocData> > FindCollocNameByRoomieId(int roomieId) { using (SqlConnection con = new SqlConnection(_connectionString)) { CollocData collocName = await con.QueryFirstOrDefaultAsync <CollocData>( @"select CollocName, CollocId from rm.vCollocInfo where RoomieId = @RoomieId;", new { RoomieId = roomieId }); // Return et procédure correctes //if( task == null ) return Result.Failure<int>( Status.NotFound, "No collocation was found for this Roomie." ); return(Result.Success(collocName)); } }
/// <summary> /// Find a colloc by it Id /// </summary> /// <param name="collocId"></param> /// <returns></returns> public async Task <Result <CollocData> > FindById(int collocId) { using (SqlConnection con = new SqlConnection(_connectionString)) { CollocData colloc = await con.QueryFirstOrDefaultAsync <CollocData>( @"select c.CollocId, c.CollocName, c.CreationDate from rm.tColloc c where c.CollocId = @CollocId;", new { CollocId = collocId }); if (colloc == null) { return(Result.Failure <CollocData>(Status.NotFound, "Colloc not found.")); } return(Result.Success(colloc)); } }