source: extensions/PiwigoLib/PiwigoLib/Service/PwgImagesService.cs @ 3827

Last change on this file since 3827 was 3827, checked in by bayral, 15 years ago

pwg.tags.getImages support

File size: 3.4 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Text;
4
5using Com.Piwigo.Lib.DTO;
6using Com.Piwigo.Lib.Proxy;
7using Com.Piwigo.Lib.Proxy.Response;
8using Com.Piwigo.Lib.DTO.Helper;
9
10namespace 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
40            foreach (PwgImageProxyResponse respImg in response.Images)
41            {
42                lstImage.Add(ConvertProxyResponseToDTO(respImg));
43            }
44        }
45
46        /// <summary>
47        /// private: convert response to dto object
48        /// </summary>
49        /// <param name="response"></param>
50        /// <param name="session"></param>
51        static public PwgImage ConvertProxyResponseToDTO(PwgImageProxyResponse response)
52        {
53            PwgImage returnValue = new PwgImage();
54
55            try
56            {
57                returnValue.Counter = response.Counter;
58                returnValue.Id = response.Id;
59                returnValue.File = response.File;
60                returnValue.Height = response.Height;
61                returnValue.Width = response.Width;
62
63                if (String.IsNullOrEmpty(response.UrlElement))
64                {
65                    returnValue.UrlElement = null;
66                }
67                else
68                {
69                    returnValue.UrlElement = (new UriBuilder(response.UrlElement)).Uri;
70                }
71
72                if (String.IsNullOrEmpty(response.UrlThunb))
73                {
74                    returnValue.UrlThunb = null;
75                }
76                else
77                {
78                    returnValue.UrlThunb = (new UriBuilder(response.UrlThunb)).Uri;
79                }
80
81                if (String.IsNullOrEmpty(response.UrlHighDef))
82                {
83                    returnValue.UrlHighDef = null;
84                }
85                else
86                {
87                    returnValue.UrlHighDef = (new UriBuilder(response.UrlHighDef)).Uri;
88                }
89
90            }
91            catch (Exception ex)
92            {
93                throw new PwgServiceException("ConvertProxyResponseToDTO : a error is raised when converting PwgTagProxyResponse.", ex);
94            }
95
96            return returnValue;
97        }
98    }
99}
Note: See TracBrowser for help on using the repository browser.