Beispiel #1
0
        public async Task <IActionResult> UpdateStatus(NewsSources inputModel)
        {
            try
            {
                await HttpHelper.PostData <NewsSources>(inputModel, $"{_domain}/api/tac-gia/update-status");

                return(Json(new { Result = true, Message = "Cập nhật dữ liệu thành công" }));
            }
            catch (Exception ex)
            {
                return(Json(new { Result = false, Message = ex.Message }));
            }
        }
Beispiel #2
0
        public async Task Update(NewsSources inputModel)
        {
            try
            {
                await _unitOfWork.NewsSourcesRepository.Update(inputModel);

                await _unitOfWork.SaveChange();
            }
            catch (Exception ex)
            {
                await _unitOfWork.Rollback();

                throw ex;
            }
        }
Beispiel #3
0
        public async Task <NewsSources> Create(NewsSources inputModel)
        {
            try
            {
                var result = await _unitOfWork.NewsSourcesRepository.Add(inputModel);

                await _unitOfWork.SaveChange();

                return(result);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Beispiel #4
0
        public async Task <IActionResult> Create([FromBody] NewsSources inputModel)
        {
            try
            {
                if (string.IsNullOrEmpty(inputModel.Name))
                {
                    throw new Exception($"Tên nguồn tin {MessageConst.NOT_EMPTY_INPUT}");
                }
                inputModel.CreatedDate = DateTime.Now;
                await _NewsSourcesManager.Create(inputModel);

                return(Ok());
            }
            catch (Exception ex)
            {
                return(StatusCode(500, ex.Message));
            }
        }
Beispiel #5
0
        public async Task <IActionResult> Delete([FromBody] NewsSources inputModel)
        {
            try
            {
                var data = await _NewsSourcesManager.Find_By_Id(inputModel.Id);

                if (data == null)
                {
                    throw new Exception($"{MessageConst.DATA_NOT_FOUND}");
                }
                await _NewsSourcesManager.Delete(inputModel.Id);

                return(Ok());
            }
            catch (Exception ex)
            {
                return(StatusCode(500, ex.Message));
            }
        }
Beispiel #6
0
        public async Task <IActionResult> Delete(NewsSources inputmodel)
        {
            try
            {
                if (inputmodel.Status == (byte)StatusEnum.Removed)
                {
                    await HttpHelper.PostData <NewsSources>(inputmodel, $"{_domain}/api/tac-gia/delete");

                    return(Json(new { Result = true }));
                }
                else
                {
                    await HttpHelper.PostData <NewsSources>(inputmodel, $"{_domain}/api/tac-gia/update-status");

                    return(Json(new { Result = true }));
                }
            }
            catch (Exception ex)
            {
                return(Json(new { Result = false, Message = ex.Message }));
            }
        }
        public async Task <IActionResult> Create_Or_Update(NewsSources inputModel)
        {
            try
            {
                if (inputModel.Id == 0)
                {
                    await HttpHelper.PostData <NewsSources>(inputModel, $"{_domain}/api/nguon-tin/create");

                    return(Json(new { Result = true, Message = "Thêm mới dữ liệu thành công" }));
                }
                else
                {
                    await HttpHelper.PostData <NewsSources>(inputModel, $"{_domain}/api/nguon-tin/update");

                    return(Json(new { Result = true, Message = "Cập nhật dữ liệu thành công" }));
                }
            }
            catch (Exception ex)
            {
                return(Json(new { Result = false, Message = ex.Message }));
            }
        }
Beispiel #8
0
        public async Task <IActionResult> Update([FromBody] NewsSources inputModel)
        {
            try
            {
                var data = await _NewsSourcesManager.Find_By_Id(inputModel.Id);

                if (data == null)
                {
                    throw new Exception(MessageConst.DATA_NOT_FOUND);
                }

                inputModel.CreatedDate = data.CreatedDate;
                inputModel.UpdatedDate = DateTime.Now;
                await _NewsSourcesManager.Update(inputModel);

                return(Ok());
            }
            catch (Exception ex)
            {
                return(StatusCode(500, ex.Message));
            }
        }
        protected override void HandleOnNavigatedTo(NavigationEventArgs e)
        {
            base.HandleOnNavigatedTo(e);
            if (!this._isInitialized)
            {
                bool flag         = false;
                long newsSourceId = 0;
                if (((Page)this).NavigationContext.QueryString.ContainsKey("NewsSourceId"))
                {
                    newsSourceId = (long)int.Parse(((Page)this).NavigationContext.QueryString["NewsSourceId"]);
                }
                if (((Page)this).NavigationContext.QueryString.ContainsKey("PhotoFeedMoveTutorial"))
                {
                    this._photoFeedMoveTutorial = ((Page)this).NavigationContext.QueryString["PhotoFeedMoveTutorial"] == bool.TrueString;
                }
                if (newsSourceId == 0L && NewsViewModel.Instance.ForceNewsFeedUpdate)
                {
                    newsSourceId = NewsSources.NewsFeed.PickableItem.ID;
                }
                if (newsSourceId != 0L)
                {
                    NewsViewModel instance = NewsViewModel.Instance;
                    PickableNewsfeedSourceItemViewModel m0 = Enumerable.FirstOrDefault <PickableNewsfeedSourceItemViewModel>(NewsSources.GetAllPredefinedNewsSources(), (Func <PickableNewsfeedSourceItemViewModel, bool>)(item => item.PickableItem.ID == newsSourceId));
                    PickableItem pickableItem = m0 != null ? m0.PickableItem : null;
                    instance.NewsSource = pickableItem;
                    flag = true;
                }
                base.DataContext = NewsViewModel.Instance;
                //NewsViewModel.Instance.EnsureUpToDate();
                if (NewsViewModel.Instance.NewsFeedVM.Collection.Count == 0)
                {
                    NewsViewModel.Instance.ReloadNews(true, true, false);
                }
                //
                NewsViewModel.Instance.FreshNewsStateChangedCallback = new Action <FreshNewsState>(this.FreshNewsStateChangedCallback);
                if (e.NavigationMode == NavigationMode.New && NewsPage._scrollPosition != 0.0 && !flag)
                {
                    this._needToScrollToOffset = true;
                    this.panelNews.Opacity     = 0.0;
                }
                this.AskToast();
                this.ucPullToRefresh.TrackListBox(this.panelNews);
                this.panelNews.OnRefresh = (Action)(() => NewsViewModel.Instance.ReloadNews(false, true, false));
                this._isInitialized      = true;
            }
            this.UpdateKeepScrollPosition();
            NewsViewModel.Instance.KeepScrollPositionChanged  = new Action(this.UpdateKeepScrollPosition);
            NewsViewModel.Instance.ShowNewsfeedTopPromoAction = new Action <UserNotification>(this.ShowNewsfeedTopPromo);
            CurrentMediaSource.AudioSource   = StatisticsActionSource.news;
            CurrentMediaSource.VideoSource   = StatisticsActionSource.news;
            CurrentMediaSource.GifPlaySource = StatisticsActionSource.news;
            CurrentMarketItemSource.Source   = MarketItemSource.feed;
            CurrentNewsFeedSource.Source     = ViewPostSource.NewsFeed;
            CurrentCommunitySource.Source    = CommunityOpenSource.Newsfeed;
            NewsViewModel.Instance.UpdateCurrentNewsFeedSource();
            this.ProcessInputParameters();
            this.HandleProtocolLaunchIfNeeded();
            this.CheckFreshNews();
            PickableItem newsSource = NewsViewModel.Instance.NewsSource;
            long?        nullable   = newsSource != null ? new long?(newsSource.ID) : new long?();

            if ((nullable.GetValueOrDefault() == NewsSources.NewsFeed.PickableItem.ID ? (nullable.HasValue ? 1 : 0) : 0) == 0 || !NewsViewModel.Instance.ForceNewsFeedUpdate)
            {
                return;
            }
            NewsViewModel.Instance.ReloadNews(true, true, false);
        }