Ejemplo n.º 1
0
        public ActionResult Index(string SearchString)
        {
            ViewBag.Right     = serNews.GetAll().Take(4);
            ViewBag.Top       = serNews.GetAll().OrderByDescending(x => x.NewsId).Take(1);
            ViewBag.Bot       = serNews.GetAll().OrderByDescending(x => x.NewsId).Take(3);
            ViewBag.Topic     = sertop.GetAll();
            ViewBag.GetAllBao = serNews.GetAll().OrderByDescending(x => x.NewsId).Take(4);
            if ((Account)Session["account"] != null)
            {
                var account = (Account)Session["account"];
            }
            if (!String.IsNullOrEmpty(SearchString))
            {
                ViewBag.Right     = serNews.GetAll().Take(4).Where(x => x.Title.ToLower().Contains(SearchString.ToLower())).ToList();
                ViewBag.Top       = serNews.GetAll().OrderByDescending(x => x.NewsId).Take(1).Where(x => x.Title.ToLower().Contains(SearchString.ToLower())).ToList();
                ViewBag.Bot       = serNews.GetAll().OrderByDescending(x => x.NewsId).Take(3).Where(x => x.Title.ToLower().Contains(SearchString.ToLower())).ToList();
                ViewBag.Topic     = sertop.GetAll();
                ViewBag.GetAllBao = serNews.GetAll().OrderByDescending(x => x.NewsId).Take(4).Where(x => x.Title.ToLower().Contains(SearchString.ToLower())).ToList();
            }
            var list = serNews.GetAll();
            List <eNewspaper> lst = new List <eNewspaper>();

            foreach (var item in list)
            {
                //lst.Add(new eNewspaper() { Active = item.Active, Description = item.Description, Image = item.Image, Journalist = item.Journalist, NewsId = item.NewsId, PublicationDate = (DateTime)item.PublicationDate, Title = item.Title });
            }
            return(View(lst));
        }
        public JsonResult getNew(int id)
        {
            TopicService     sertop  = new TopicService();
            MappingService   sermap  = new MappingService();
            NewspaperService sernews = new NewspaperService();

            if (id == 0)
            {
                return(Json(sernews.GetAll(), JsonRequestBehavior.AllowGet));
            }
            else
            {
                var query = (from tp in sertop.GetAll()
                             join
                             map in sermap.GetAll() on tp.TopicId equals map.TopicId
                             join
                             news in sernews.GetAll() on map.NewsId equals news.NewsId
                             where tp.TopicId == id
                             select new
                {
                    news.Image,
                    news.Title,
                    tp.TopicName,
                    news.NewsId
                }).ToList();
                ViewBag.getbaotheoIDTopic = query;

                return(Json(query, JsonRequestBehavior.AllowGet));
            }
        }
        // GET: Category
        public ActionResult Index()
        {
            TopicService      sertop  = new TopicService();
            List <eTopic>     lst     = new List <eTopic>();
            List <eNewspaper> listbao = new List <eNewspaper>();
            NewspaperService  serbao  = new NewspaperService();

            foreach (var item in serbao.GetAll())
            {
                listbao.Add(new eNewspaper()
                {
                    Title           = item.Title,
                    Active          = item.Active,
                    Description     = item.Description,
                    Image           = item.Image,
                    Journalist      = item.Journalist,
                    NewsId          = item.NewsId,
                    PublicationDate = (DateTime)item.PublicationDate
                });
            }
            ViewBag.ALlBao = listbao;
            foreach (var item in sertop.GetAll())
            {
                eTopic top = new eTopic()
                {
                    TopicId = item.TopicId, TopicName = item.TopicName
                };
                lst.Add(top);
            }
            return(View(lst));
        }
Ejemplo n.º 4
0
        // GET: Forum
        public ActionResult First()
        {
            var client  = new RestClient("http://localhost:18080/insurance-web/api/");
            var request = new RestRequest("Category", Method.GET);

            request.AddHeader("Content-type", "application/json");
            IRestResponse <List <category> > Cat = client.Execute <List <category> >(request);


            ViewBag.topic       = Ts.GetAll();
            ViewBag.soucategory = Ss.GetAll();
            ViewBag.message     = Ms.GetAll();
            ViewBag.user        = Us.GetAll();


            return(View(Cs.GetAll()));
        }
Ejemplo n.º 5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                var query = (string)RouteData.Values["query"];

                if (!string.IsNullOrEmpty(query))
                {
                    var result = CategoryService.GetAll()
                                 .Where(x => x.Name.ToUpper().Trim().Contains(query.ToUpper().Trim()))
                                 .Take(MaxResultsPerType)
                                 .Select(x => new
                    {
                        DsiplayName       = "#Categorie " + x.Name,
                        IsHyperlinkResult = true,
                        NavigateUrl       = GetRouteUrl("Category", new { categoryId = x.Id }),
                        IsContentResult   = false,
                        ContentResult     = string.Empty
                    }).Union(SubjectService.GetAll()
                             .Where(x => x.Name.ToUpper().Trim().Contains(query.ToUpper().Trim()))
                             .Take(MaxResultsPerType)
                             .Select(x => new
                    {
                        DsiplayName       = "#Subiect " + x.Name,
                        IsHyperlinkResult = true,
                        NavigateUrl       = GetRouteUrl("SubjectTopics", new { subjectId = x.Id }),
                        IsContentResult   = false,
                        ContentResult     = string.Empty
                    })).Union(TopicService.GetAll()
                              .Where(x => x.Name.ToUpper().Trim().Contains(query.ToUpper().Trim()))
                              .Take(MaxResultsPerType)
                              .Select(x => new
                    {
                        DsiplayName       = "#Topic " + x.Name,
                        IsHyperlinkResult = true,
                        NavigateUrl       = GetRouteUrl("TopicPosts", new { topicId = x.Id }),
                        IsContentResult   = false,
                        ContentResult     = string.Empty
                    })).Union(PostService.GetAll()
                              .Where(x => x.Text.ToUpper().Trim().Contains(query.ToUpper().Trim()))
                              .Take(MaxResultsPerType)
                              .Select(x => new
                    {
                        DsiplayName       = "#Postare",
                        IsHyperlinkResult = true,
                        NavigateUrl       = GetRouteUrl("TopicPosts", new { topicId = x.Topic.Id }),
                        IsContentResult   = true,
                        ContentResult     = x.Text
                    }));

                    this.searchResultListView.DataSource = result;
                    DataBind();
                }
            }
        }
Ejemplo n.º 6
0
 public ActionResult CreateNews()
 {
     if (Session["account"] is null)
     {
         return(RedirectToAction("Login", "Login"));
     }
     else
     {
         TopicService sv = new TopicService();
         NewInfo      s  = new NewInfo();
         s.Topic = sv.GetAll().ToList();
         return(View(s));
     }
 }
Ejemplo n.º 7
0
        public void TestGetAll()
        {
            IEnumerable <Topic> topics = new List <Topic>()
            {
                new Topic()
                {
                    Id     = "ads6safasf5f5asf4asf5",
                    Name   = "Thien nhien",
                    ImgUrl = "https://storage.googleapis.com/trip-sharing-final-image-bucket/image-201907201619337977-3i9uvrioa3noa7c3.jpg"
                }
            };

            mockTopicRepository.Setup(x => x.GetAll()).Returns(topics);
            var topicService = new TopicService(mockTopicRepository.Object);
            IEnumerable <Topic> list_topics = topicService.GetAll();

            Assert.IsNotNull(list_topics);
        }
Ejemplo n.º 8
0
        public ActionResult UpdateNews(int newsid = 11)
        {
            if (Session["account"] is null)
            {
                return(RedirectToAction("Login", "Login"));
            }
            else
            {
                var account              = Session["account"] as Account;
                NewspaperService svn     = new NewspaperService();
                var            result    = svn.GetById(newsid);
                MappingService svm       = new MappingService();
                var            mapresult = svm.GetAll().Where(x => x.NewsId == result.NewsId).ToList();
                List <Topic>   lsttopic  = new List <Topic>();
                TopicService   svt       = new TopicService();
                foreach (var item in mapresult)
                {
                    lsttopic.Add(svt.GetById(item.TopicId));
                }
                string str = "";
                foreach (var item in lsttopic)
                {
                    str += item.TopicId + ",";
                }
                str = str.Substring(0, str.Length - 1);

                ViewBag.GetTopic = str;
                NewInfo newinfo = new NewInfo();
                newinfo.Title       = result.Title;
                newinfo.NewsId      = result.NewsId;
                newinfo.Image       = result.Image;
                newinfo.Journalist  = account.AccountName;
                newinfo.Description = result.Description;
                newinfo.Topic       = svt.GetAll().ToList();
                return(View(newinfo));
            }
        }
Ejemplo n.º 9
0
        // GET: Members/Home
        public ActionResult Index()
        {
            var topic = _topicSevice.GetAll();

            return(View(topic));
        }
Ejemplo n.º 10
0
 public async Task <ICollection <Topic> > List()
 {
     return(await topicService.GetAll());
 }
Ejemplo n.º 11
0
 public async Task <ActionResult <TopicDto[]> > GetTopics()
 {
     return(await _topicService.GetAll());
 }
Ejemplo n.º 12
0
        public async void GetTopicAll()
        {
            try
            {
                var checkNet    = true;
                int workingStep = 1;
                retry = 1;
                int loopcheck = 0;

                bool internetCheck = true;
                do
                {
                    switch (workingStep)
                    {
                    case 1:                            //check internet
                        checkNet = CheckingInternet();
                        if (checkNet == true)
                        {
                            workingStep = 10;
                        }
                        else
                        {
                            workingStep = 2;
                        }
                        break;

                    case 2:                            //delay
                        //	await Task.Delay(300);
                        workingStep = 3;
                        break;

                    case 3:                            //action result
                        bool istryAgain = await Application.Current.MainPage.DisplayAlert("", "No Internet", "Try Again", "Cancel");

                        if (istryAgain)
                        {
                            workingStep = 1;
                        }
                        else
                        {
                            internetCheck = false;
                        }
                        break;

                    case 10:                            //call api
                        loopcheck++;

                        HeadTopics = await TopicService.GetAll();

                        if (BlogsForYou.StatusCode == Enums.StatusCode.Ok)
                        {
                            List <TopicDto> blogModel = new List <TopicDto>();
                            List <TopicDto> data      = HeadTopics.Success;
                            blogModel   = data;
                            ListTopic   = new ObservableCollection <TopicDto>(blogModel);
                            workingStep = 100;
                        }
                        else
                        {
                            if (loopcheck <= maxRetry)
                            {
                                if (HeadTopics.StatusCode == Enums.StatusCode.Unauthorized)
                                {
                                    //await GetToken();
                                }
                                else
                                {
                                    workingStep++;
                                }
                            }
                            else
                            {
                                internetCheck = false;
                            }
                        }
                        break;

                    case 11:                            //
                                                        //await Task.Delay(300);
                        workingStep++;
                        break;

                    case 12:                            //
                        if (HeadTopics.StatusCode == Enums.StatusCode.BadRequest)
                        {
                        }
                        else if (HeadTopics.StatusCode == Enums.StatusCode.NotFound)
                        {
                        }
                        else if (HeadTopics.StatusCode == Enums.StatusCode.InternalServerError)
                        {
                        }
                        else
                        {
                        }
                        workingStep++;
                        break;

                    default:
                        internetCheck = false;
                        break;
                    }
                } while (internetCheck);
            }
            catch (OperationCanceledException)
            {
            }
            catch (TimeoutException)
            {
            }
        }