File tree Expand file tree Collapse file tree 4 files changed +39
-6
lines changed Expand file tree Collapse file tree 4 files changed +39
-6
lines changed Original file line number Diff line number Diff line change 207207 <DependentUpon >Global.asax</DependentUpon >
208208 </Compile >
209209 <Compile Include =" Models\Banner.cs" />
210+ <Compile Include =" Models\BannerDetailDTO.cs" />
210211 <Compile Include =" Models\BannerDTO.cs" />
211212 <Compile Include =" Properties\AssemblyInfo.cs" />
212213 <Compile Include =" Repositories\BannerRepository.cs" />
Original file line number Diff line number Diff line change @@ -21,13 +21,13 @@ public BannerController()
2121 }
2222
2323 // GET api/Banner
24- public IEnumerable < Banner > Get ( )
24+ public IEnumerable < BannerDetailDTO > Get ( )
2525 {
2626 return bannerService . GetAll ( ) ;
2727 }
2828
2929 // GET api/Banners/int
30- public Banner Get ( int id )
30+ public BannerDetailDTO Get ( int id )
3131 {
3232 var banner = bannerService . Get ( id ) ;
3333 if ( banner == null )
Original file line number Diff line number Diff line change 1+ using System ;
2+ using System . Collections . Generic ;
3+ using System . Linq ;
4+ using System . Web ;
5+
6+ namespace BannerFlow . Models
7+ {
8+ public class BannerDetailDTO
9+ {
10+ public int Id { get ; set ; }
11+ public string Html { get ; set ; }
12+ public DateTime Created { get ; set ; }
13+ public DateTime ? Modified { get ; set ; }
14+
15+ public BannerDetailDTO ( Banner banner )
16+ {
17+ this . Id = banner . Id ;
18+ this . Html = banner . Html ;
19+ this . Created = banner . Created ;
20+ this . Modified = banner . Modified ;
21+ }
22+ }
23+ }
Original file line number Diff line number Diff line change @@ -36,15 +36,24 @@ public Banner Add(BannerDTO data)
3636 }
3737
3838 // Return all entries logic
39- public IEnumerable < Banner > GetAll ( )
39+ public IEnumerable < BannerDetailDTO > GetAll ( )
4040 {
41- return repository . GetAll ( ) ;
41+ List < BannerDetailDTO > value = new List < BannerDetailDTO > ( ) ;
42+ IEnumerable < Banner > banners = repository . GetAll ( ) ;
43+
44+ foreach ( Banner x in banners )
45+ {
46+ value . Add ( new BannerDetailDTO ( x ) ) ;
47+ }
48+ return value ;
4249 }
4350
4451 // Return requested entry logic
45- public Banner Get ( int id )
52+ public BannerDetailDTO Get ( int id )
4653 {
47- return repository . Get ( id ) ;
54+ BannerDetailDTO value = new BannerDetailDTO ( repository . Get ( id ) ) ;
55+
56+ return value ;
4857 }
4958
5059
You can’t perform that action at this time.
0 commit comments