예제 #1
0
        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));
            }
        }
예제 #2
0
        /// <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));
            }
        }