public ExtraDetails MapEntitiesToObjects(IEnumerable <TWMBILLINGMORE> entities)
        {
            ExtraDetails obj = null;

            if (entities != null && entities.Count() > 0)
            {
                obj = new ExtraDetails();

                foreach (var item in entities)
                {
                    try
                    {
                        obj.workRequestId = item.CD_WR.ToString();
                        obj.district      = item.CD_DIST;
                        obj.GetType().GetProperty(item.NM_FIELD.ToString()).SetValue(obj, GetTxtValue(item), null);
                    }
                    catch (NullReferenceException)
                    {
                        //Property Does Not Exist Under ExtraDetails
                    }
                }
            }

            return(obj);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Lookup an item and get details about it.
 /// </summary>
 /// <param name="client">An IXboxMusicClient instance.</param>
 /// <param name="itemId">Id to look up, prefixed by a namespace: {namespace.id}.</param>
 /// <param name="source">The content source: Catalog, Collection or both</param>
 /// <param name="language">ISO 2 letter code.</param>
 /// <param name="country">ISO 2 letter code.</param>
 /// <param name="extras">Enumeration of extra details.</param>
 /// <returns> Content response with details about one or more items.</returns>
 public static Task <ContentResponse> LookupAsync(this IXboxMusicClient client, string itemId, ContentSource?source = null, string language = null,
                                                  string country = null, ExtraDetails extras = ExtraDetails.None)
 {
     return(client.LookupAsync(new List <string> {
         itemId
     }, source, language, country, extras));
 }
Exemplo n.º 3
0
 public Task <ContentResponse> SubBrowseContinuationAsync(
     string id,
     ContentSource source,
     BrowseItemType browseType,
     ExtraDetails extra,
     string continuationToken)
 {
     return(SubBrowseApiAsync(id, source, browseType, extra, continuationToken: continuationToken));
 }
Exemplo n.º 4
0
 public Task <ContentResponse> LookupAsync(
     List <string> itemIds,
     ContentSource?source = null,
     string language      = null,
     string country       = null,
     ExtraDetails extras  = ExtraDetails.None)
 {
     return(LookupApiAsync(itemIds, source, language, country, extras));
 }
        public void Update(ExtraDetails obj)
        {
            List <TWMBILLINGMORE> entities = MapObjectToEntity(obj).ToList();

            if (entities != null && entities.Count > 0)
            {
                foreach (var item in entities)
                {
                    unitOfWork.BillingMoreRepo.Update(item);
                }
            }
        }
Exemplo n.º 6
0
 public Task <ContentResponse> SubBrowseAsync(
     string id,
     ContentSource source,
     BrowseItemType browseType,
     ExtraDetails extra,
     OrderBy?orderBy = null,
     int?maxItems    = null,
     int?page        = null,
     string language = null,
     string country  = null)
 {
     return(SubBrowseApiAsync(id, source, browseType, extra, orderBy, maxItems, page, language, country));
 }
Exemplo n.º 7
0
        private async Task <ContentResponse> SubBrowseApiAsync(
            string id,
            ContentSource source,
            BrowseItemType browseType,
            ExtraDetails extra,
            OrderBy?orderBy          = null,
            int?maxItems             = null,
            int?page                 = null,
            string language          = null,
            string country           = null,
            string continuationToken = null)
        {
            Dictionary <string, string> requestParameters = FormatRequestParameters(continuationToken, language, country);

            if (orderBy.HasValue)
            {
                requestParameters.Add("orderby", orderBy.ToString());
            }

            if (maxItems.HasValue)
            {
                requestParameters.Add("maxitems", maxItems.ToString());
            }

            if (page.HasValue)
            {
                requestParameters.Add("page", page.ToString());
            }

            if (_userTokenManager?.UserIsSignedIn == true)
            {
                return(await ApiCallWithUserAuthorizationHeaderRefreshAsync(
                           headers => GetAsync <ContentResponse>(
                               Hostname,
                               $"/1/content/{id}/{source}/{browseType}/{extra}/browse",
                               new CancellationToken(false),
                               requestParameters,
                               headers)));
            }
            else
            {
                Dictionary <string, string> requestHeaders = await FormatRequestHeadersAsync(null);

                return(await GetAsync <ContentResponse>(
                           Hostname,
                           $"/1/content/{id}/{source}/{browseType}/{extra}/browse",
                           new CancellationToken(false),
                           requestParameters,
                           requestHeaders));
            }
        }
        public void Delete(ExtraDetails obj)
        {
            IEnumerable <TWMBILLINGMORE> entities = MapObjectToEntity(obj);

            if (entities.Count() > 0)
            {
                foreach (var item in entities)
                {
                    unitOfWork.BillingMoreRepo.Delete(item.CD_DIST, item.CD_WR, item.NM_FIELD);
                }

                unitOfWork.Save();
            }
        }
        public void Create(ExtraDetails obj)
        {
            if (obj != null)
            {
                IEnumerable <TWMBILLINGMORE> entities = MapObjectToEntity(obj);

                Delete(obj);

                foreach (var item in entities)
                {
                    unitOfWork.BillingMoreRepo.Insert(item);
                }

                unitOfWork.Save();
            }
        }
Exemplo n.º 10
0
        private async Task <ContentResponse> LookupApiAsync(
            IEnumerable <string> itemIds,
            ContentSource?source     = null,
            string language          = null,
            string country           = null,
            ExtraDetails extras      = ExtraDetails.None,
            string continuationToken = null)
        {
            Dictionary <string, string> requestParameters = FormatRequestParameters(continuationToken, language, country, source);

            if (extras != ExtraDetails.None)
            {
                string extra = extras.ToString().Replace(", ", "+");
                requestParameters.Add("extras", extra);
            }

            string ids = itemIds.Aggregate("",
                                           (current, id) =>
                                           current + (!string.IsNullOrEmpty(current) ? "+" : "") + id);

            if (_userTokenManager?.UserIsSignedIn == true)
            {
                return(await ApiCallWithUserAuthorizationHeaderRefreshAsync(
                           headers => GetAsync <ContentResponse>(
                               Hostname,
                               $"/1/content/{ids}/lookup",
                               new CancellationToken(false),
                               requestParameters,
                               headers)));
            }
            else
            {
                Dictionary <string, string> requestHeaders = await FormatRequestHeadersAsync(null);

                return(await GetAsync <ContentResponse>(
                           Hostname,
                           $"/1/content/{ids}/lookup",
                           new CancellationToken(false),
                           requestParameters,
                           requestHeaders));
            }
        }
        public IEnumerable <TWMBILLINGMORE> MapObjectToEntity(ExtraDetails obj)
        {
            List <TWMBILLINGMORE> entity = new List <TWMBILLINGMORE>();

            foreach (System.Reflection.PropertyInfo item in new List <System.Reflection.PropertyInfo>(obj.GetType().GetProperties()))
            {
                var ent = new TWMBILLINGMORE();

                ent.CD_DIST   = obj.district;
                ent.CD_WR     = Convert.ToInt64(obj.workRequestId);
                ent.TXT_VALUE = (string)item.GetValue(obj, null);
                ent.NM_FIELD  = item.Name;

                if (item.Name != "workRequestId" && item.Name != "district")
                {
                    ent.TXT_VALUE = (string)item.GetValue(obj, null);
                    ent.NM_FIELD  = item.Name;

                    entity.Add(ent);
                }
            }

            return(entity);
        }
Exemplo n.º 12
0
        private async Task <ContentResponse> SubBrowseApiAsync(string id, ContentSource source, BrowseItemType browseType, ExtraDetails extra, OrderBy?orderBy = null, int?maxItems = null, int?page = null, string language = null, string country = null, string continuationToken = null)
        {
            Dictionary <string, string> requestParameters = await FormatRequestParametersAsync(continuationToken, language, country);

            if (orderBy.HasValue)
            {
                requestParameters.Add("orderby", orderBy.ToString());
            }
            if (maxItems.HasValue)
            {
                requestParameters.Add("maxitems", maxItems.ToString());
            }
            if (page.HasValue)
            {
                requestParameters.Add("page", page.ToString());
            }
            return(await GetWithRetryOnExpiredTokenAsync <ContentResponse>(
                       "/1/content/" + id + "/" + source + "/" + browseType + "/" + extra + "/browse",
                       new CancellationToken(false), requestParameters));
        }
Exemplo n.º 13
0
        private async Task <ContentResponse> LookupApiAsync(IEnumerable <string> itemIds, ContentSource?source = null,
                                                            string language          = null, string country = null, ExtraDetails extras = ExtraDetails.None,
                                                            string continuationToken = null)
        {
            Dictionary <string, string> requestParameters = await FormatRequestParametersAsync(continuationToken, language, country, source);

            if (extras != ExtraDetails.None)
            {
                string extra = extras.ToString().Replace(", ", "+");
                requestParameters.Add("extras", extra);
            }
            string ids = itemIds.Aggregate("",
                                           (current, id) => current + (!String.IsNullOrEmpty(current) ? "+" : "") + id);

            return(await GetWithRetryOnExpiredTokenAsync <ContentResponse>("/1/content/" + ids + "/lookup", new CancellationToken(false),
                                                                           requestParameters));
        }
 /// <summary>
 /// Lookup an item and get details about it.
 /// </summary>
 /// <param name="client">An IXboxMusicClient instance.</param>
 /// <param name="itemId">Id to look up, prefixed by a namespace: {namespace.id}.</param>
 /// <param name="source">The content source: Catalog, Collection or both</param>
 /// <param name="language">ISO 2 letter code.</param>
 /// <param name="country">ISO 2 letter code.</param>
 /// <param name="extras">Enumeration of extra details.</param>
 /// <returns> Content response with details about one or more items.</returns>
 public static Task<ContentResponse> LookupAsync(this IXboxMusicClient client, string itemId, ContentSource? source = null, string language = null,
     string country = null, ExtraDetails extras = ExtraDetails.None)
 {
     return client.LookupAsync(new List<string> { itemId }, source, language, country, extras);
 }