Ejemplo n.º 1
0
        public ActionResult Save(NewsAndEvents newsAndEvents)
        {
            var res = _newsEventService.Save(newsAndEvents);

            return(Json(new Response
            {
                Success = res,
                Message = res ? Resource.SavedSuccessfully : Resource.ErrorsOccurred,
                Data = new { NewsAndEventsId = newsAndEvents.Id }
            }));
        }
Ejemplo n.º 2
0
        public ActionResult SaveNewsAndEventsPhoto(long NewsAndEventsId)
        {
            var files    = Request.Files;
            var uploaded = _fileService.UploadFile(MyConstants.UploadsPath, files[0]);

            NewsAndEvents newsAndEvents = _newsEventService.FirstOrDefault(x => x.Id == NewsAndEventsId);

            newsAndEvents.AttachmentUrl = uploaded.Path;

            _newsEventService.Update(newsAndEvents);
            _newsEventService.SaveChanges();
            return(Json(true));
        }
Ejemplo n.º 3
0
        public async Task SetData()
        {
            HttpClient httpClient = new HttpClient();
            var        html       = await httpClient.GetStringAsync(@"http://piranigroup.com.pk/news-events/");

            HtmlDocument htmlDocument = new HtmlDocument();

            htmlDocument.LoadHtml(html);

            var nodes = htmlDocument.DocumentNode
                        .Descendants("div")
                        .Where(n => n.GetAttributeValue("class", "").Equals("rbs-img-image  rbs-lightbox"));

            foreach (var node in nodes)
            {
                var newsAndEvent = new NewsAndEvents
                {
                    ThumbNail = node.Descendants("div").FirstOrDefault()?.ChildAttributes("data-thumbnail").FirstOrDefault()?.Value
                };

                NewsAndEventsCollection.Add(newsAndEvent);
            }
        }