[3827] | 1 | using System; |
---|
| 2 | using System.Collections.Generic; |
---|
| 3 | using System.Text; |
---|
| 4 | |
---|
| 5 | using Com.Piwigo.Lib.DTO; |
---|
| 6 | using Com.Piwigo.Lib.Proxy; |
---|
| 7 | using Com.Piwigo.Lib.Proxy.Response; |
---|
| 8 | using Com.Piwigo.Lib.DTO.Helper; |
---|
| 9 | |
---|
| 10 | namespace Com.Piwigo.Lib.Service |
---|
| 11 | { |
---|
| 12 | |
---|
| 13 | static public class PwgImagesService |
---|
| 14 | { |
---|
| 15 | /// <summary> |
---|
| 16 | /// private: convert response to dto object |
---|
| 17 | /// </summary> |
---|
| 18 | /// <param name="response"></param> |
---|
| 19 | /// <param name="session"></param> |
---|
| 20 | static public void ConvertProxyResponseToDTO(PwgImagesProxyResponse response, |
---|
| 21 | List<PwgImage> lstImage, |
---|
| 22 | ref Int32 Page, ref Int32 PerPagee, ref Int32 Count) |
---|
| 23 | { |
---|
| 24 | ConvertProxyResponseToDTO(response.ImageList, lstImage, ref Page, ref PerPagee, ref Count); |
---|
| 25 | } |
---|
| 26 | |
---|
| 27 | /// <summary> |
---|
| 28 | /// private: convert response to dto object |
---|
| 29 | /// </summary> |
---|
| 30 | /// <param name="response"></param> |
---|
| 31 | /// <param name="session"></param> |
---|
| 32 | static public void ConvertProxyResponseToDTO(PwgImageListProxyResponse response, |
---|
| 33 | List<PwgImage> lstImage, |
---|
| 34 | ref Int32 Page, ref Int32 PerPagee, ref Int32 Count) |
---|
| 35 | { |
---|
| 36 | Page = response.Page; |
---|
| 37 | PerPagee = response.PerPage; |
---|
| 38 | Count = response.Count; |
---|
| 39 | |
---|
[3835] | 40 | if (response.Images != null) |
---|
[3827] | 41 | { |
---|
[3835] | 42 | foreach (PwgImageProxyResponse respImg in response.Images) |
---|
| 43 | { |
---|
| 44 | lstImage.Add(ConvertProxyResponseToDTO(respImg)); |
---|
| 45 | } |
---|
[3827] | 46 | } |
---|
| 47 | } |
---|
| 48 | |
---|
| 49 | /// <summary> |
---|
| 50 | /// private: convert response to dto object |
---|
| 51 | /// </summary> |
---|
| 52 | /// <param name="response"></param> |
---|
| 53 | /// <param name="session"></param> |
---|
| 54 | static public PwgImage ConvertProxyResponseToDTO(PwgImageProxyResponse response) |
---|
| 55 | { |
---|
| 56 | PwgImage returnValue = new PwgImage(); |
---|
| 57 | |
---|
| 58 | try |
---|
| 59 | { |
---|
| 60 | returnValue.Counter = response.Counter; |
---|
| 61 | returnValue.Id = response.Id; |
---|
| 62 | returnValue.File = response.File; |
---|
| 63 | returnValue.Height = response.Height; |
---|
| 64 | returnValue.Width = response.Width; |
---|
| 65 | |
---|
| 66 | if (String.IsNullOrEmpty(response.UrlElement)) |
---|
| 67 | { |
---|
| 68 | returnValue.UrlElement = null; |
---|
| 69 | } |
---|
| 70 | else |
---|
| 71 | { |
---|
| 72 | returnValue.UrlElement = (new UriBuilder(response.UrlElement)).Uri; |
---|
| 73 | } |
---|
| 74 | |
---|
| 75 | if (String.IsNullOrEmpty(response.UrlThunb)) |
---|
| 76 | { |
---|
| 77 | returnValue.UrlThunb = null; |
---|
| 78 | } |
---|
| 79 | else |
---|
| 80 | { |
---|
| 81 | returnValue.UrlThunb = (new UriBuilder(response.UrlThunb)).Uri; |
---|
| 82 | } |
---|
| 83 | |
---|
| 84 | if (String.IsNullOrEmpty(response.UrlHighDef)) |
---|
| 85 | { |
---|
| 86 | returnValue.UrlHighDef = null; |
---|
| 87 | } |
---|
| 88 | else |
---|
| 89 | { |
---|
| 90 | returnValue.UrlHighDef = (new UriBuilder(response.UrlHighDef)).Uri; |
---|
| 91 | } |
---|
| 92 | |
---|
[3828] | 93 | returnValue.Tags = new List<PwgTag>(); |
---|
[3835] | 94 | if (response.Tags != null) |
---|
[3828] | 95 | { |
---|
[3835] | 96 | foreach (PwgTagProxyResponse tagResp in response.Tags) |
---|
| 97 | { |
---|
| 98 | PwgTag aTag = PwgTagsService.ConvertProxyResponseToDTO(tagResp); |
---|
| 99 | returnValue.Tags.Add(aTag); |
---|
| 100 | } |
---|
[3828] | 101 | } |
---|
| 102 | |
---|
[3835] | 103 | returnValue.Categories = new List<PwgCategory>(); |
---|
| 104 | if (response.Categories != null) |
---|
| 105 | { |
---|
| 106 | foreach (PwgCategoryProxyResponse catResp in response.Categories) |
---|
| 107 | { |
---|
| 108 | PwgCategory aCat = PwgCategoriesService.ConvertProxyResponseToDTO(catResp); |
---|
| 109 | returnValue.Categories.Add(aCat); |
---|
| 110 | } |
---|
| 111 | } |
---|
| 112 | |
---|
[3827] | 113 | } |
---|
| 114 | catch (Exception ex) |
---|
| 115 | { |
---|
| 116 | throw new PwgServiceException("ConvertProxyResponseToDTO : a error is raised when converting PwgTagProxyResponse.", ex); |
---|
| 117 | } |
---|
| 118 | |
---|
| 119 | return returnValue; |
---|
| 120 | } |
---|
| 121 | } |
---|
| 122 | } |
---|