Ignore:
Timestamp:
Sep 3, 2009, 4:03:22 PM (15 years ago)
Author:
bayral
Message:

get Tags List support

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/PiwigoLib/PiwigoLib/Service/PwgTagsService.cs

    r3816 r3818  
    1010namespace Com.Piwigo.Lib.Service
    1111{
    12  
     12
    1313    static public class PwgTagsService
    1414    {
    15 
    16         static public List<PwgTag> GetListOfPwgTag(Boolean sortedByCounter)
     15        /// <summary>
     16        /// Get the list of tags the user is connected can access
     17        /// </summary>
     18        /// <param name="sortedByCounter"></param>
     19        /// <returns></returns>
     20        static public List<PwgTag> GetListOfTag(Boolean sortedByCounter)
    1721        {
    1822            List<PwgTag> returnValue = new List<PwgTag>();
     
    4852
    4953        /// <summary>
     54        /// Get the list of all atgs in piwigo, you must be connected with a high level user
     55        /// </summary>
     56        /// <param name="sortedByCounter"></param>
     57        /// <returns></returns>
     58        static public List<PwgTag> GetAdminListOfTag()
     59        {
     60            List<PwgTag> returnValue = new List<PwgTag>();
     61
     62            try
     63            {
     64                PwgTagsProxyResponse response = PwgTagsProxy.pwg_tags_getAdminList();
     65
     66                if (response.Retour != PwgBaseProxyReponseRetourEnum.Ok)
     67                {
     68                    if (response.Erreur != null)
     69                    {
     70                        throw new PwgServiceException("GetAdminListOfTag, the server has return the error.",
     71                            response.Erreur.Code,
     72                            response.Erreur.Message);
     73                    }
     74                    else
     75                    {
     76                        throw new PwgServiceException("GetAdminListOfTag : a error occurs during server process.");
     77                    }
     78                }
     79                else
     80                {
     81                    returnValue = ConvertProxyResponseToDTO(response);
     82                }
     83            }
     84            catch (PwgProxyException ex)
     85            {
     86                throw new PwgServiceException("GetAdminListOfTag : a error is raised by proxy.", ex);
     87            }
     88            return returnValue;
     89        }
     90
     91
     92        /// <summary>
    5093        /// private: convert response to dto object
    5194        /// </summary>
     
    5699            List<PwgTag> returnValue = new List<PwgTag>();
    57100
     101            foreach (PwgTagProxyResponse respTag in response.Tags)
     102            {
     103                returnValue.Add(ConvertProxyResponseToDTO(respTag));
     104            }
     105
     106            return returnValue;
     107        }
     108
     109        /// <summary>
     110        /// private: convert response to dto object
     111        /// </summary>
     112        /// <param name="response"></param>
     113        /// <param name="session"></param>
     114        static private PwgTag ConvertProxyResponseToDTO(PwgTagProxyResponse response)
     115        {
     116            PwgTag returnValue = new PwgTag();
     117
     118            try
     119            {
     120                returnValue.Counter = response.Counter;
     121                returnValue.Id = response.Id;
     122                returnValue.Name = response.Name;
     123                returnValue.UrlName = response.UrlName;
     124
     125                if (String.IsNullOrEmpty(response.UrlTag))
     126                {
     127                    returnValue.UrlTag = null;
     128                }
     129                else
     130                {
     131                    returnValue.UrlTag = (new UriBuilder(response.UrlTag)).Uri;
     132                }
     133            }
     134            catch (Exception ex)
     135            {
     136                throw new PwgServiceException("ConvertProxyResponseToDTO : a error is raised when converting PwgTagProxyResponse.", ex);
     137            }
     138
    58139            return returnValue;
    59140        }
Note: See TracChangeset for help on using the changeset viewer.