using System; using System.Collections.Generic; using System.Text; using Com.Piwigo.Lib.DTO; using Com.Piwigo.Lib.Proxy; using Com.Piwigo.Lib.Proxy.Response; using Com.Piwigo.Lib.DTO.Helper; namespace Com.Piwigo.Lib.Service { static public class PwgImagesService { /// /// private: convert response to dto object /// /// /// static public void ConvertProxyResponseToDTO(PwgImagesProxyResponse response, List lstImage, ref Int32 Page, ref Int32 PerPagee, ref Int32 Count) { ConvertProxyResponseToDTO(response.ImageList, lstImage, ref Page, ref PerPagee, ref Count); } /// /// private: convert response to dto object /// /// /// static public void ConvertProxyResponseToDTO(PwgImageListProxyResponse response, List lstImage, ref Int32 Page, ref Int32 PerPagee, ref Int32 Count) { Page = response.Page; PerPagee = response.PerPage; Count = response.Count; foreach (PwgImageProxyResponse respImg in response.Images) { lstImage.Add(ConvertProxyResponseToDTO(respImg)); } } /// /// private: convert response to dto object /// /// /// static public PwgImage ConvertProxyResponseToDTO(PwgImageProxyResponse response) { PwgImage returnValue = new PwgImage(); try { returnValue.Counter = response.Counter; returnValue.Id = response.Id; returnValue.File = response.File; returnValue.Height = response.Height; returnValue.Width = response.Width; if (String.IsNullOrEmpty(response.UrlElement)) { returnValue.UrlElement = null; } else { returnValue.UrlElement = (new UriBuilder(response.UrlElement)).Uri; } if (String.IsNullOrEmpty(response.UrlThunb)) { returnValue.UrlThunb = null; } else { returnValue.UrlThunb = (new UriBuilder(response.UrlThunb)).Uri; } if (String.IsNullOrEmpty(response.UrlHighDef)) { returnValue.UrlHighDef = null; } else { returnValue.UrlHighDef = (new UriBuilder(response.UrlHighDef)).Uri; } returnValue.Tags = new List(); foreach (PwgTagProxyResponse tagResp in response.Tags) { PwgTag aTag = PwgTagsService.ConvertProxyResponseToDTO(tagResp); returnValue.Tags.Add(aTag); } } catch (Exception ex) { throw new PwgServiceException("ConvertProxyResponseToDTO : a error is raised when converting PwgTagProxyResponse.", ex); } return returnValue; } } }