예제 #1
0
        public async Task <int> RefreshLatestData(Guid feedId, Guid publisherId, bool refresh)
        {
            try
            {
                int updated = 0;
                IsLoading = true;

                if (feedId.Equals(default(Guid)) || publisherId.Equals(default(Guid)))
                {
                    return(0);
                }

                var feedResult = _feedManager.GetSubscribedFeed(feedId);
                if (feedResult.HasError || !feedResult.Target.Publisher.Id.Equals(publisherId))
                {
                    return(0);
                }

                if (FeedHelper.ShouldUpdateItems(feedResult.Target) || refresh)
                {
                    try
                    {
                        var updateResult = await _feedManager.UpdateItems(feedResult.Target, true);

                        updated = updateResult.HasError ? 0 : updateResult.Target;
                    }
                    catch (Exception ex)
                    {
                        updated = -1;
                        GA.LogException(ex);
                    }
                }

                UpdateFromDomainModel(feedResult.Target);
                IsLoading = false;
                return(updated);
            }
            catch (Exception ex)
            {
                IsLoading = false;
                throw ex;
            }
        }