public ActionResult Edit([Bind(Exclude = "Image")] NewsHeader newsHeader, HttpPostedFileBase Image)
        {
            if (ModelState.IsValid)
            {
                if (Image != null)
                {
                    if (Extensions.Extensions.CheckImageType(Image) && Extensions.Extensions.CheckImageSize(Image, 10))
                    {
                        newsHeader.Image = Extensions.Extensions.SaveImage(Server.MapPath("~/Public/images"), Image);


                        db.Entry(newsHeader).State = EntityState.Modified;
                        db.SaveChanges();

                        return(RedirectToAction("Index", "NewsHeader"));
                    }
                    else
                    {
                        ModelState.AddModelError("Image", "The type of image is incorrect or the size of image is greater than 10 Mb.");
                    }
                }
                else
                {
                    ModelState.AddModelError("Image", "Please choose an image");
                }
            }
            return(View());
        }
示例#2
0
        public static NewsHeader[] Parse(string xml, string rssClass)
        {
            xml = xml.Replace("content:encoded", "description");


            XmlDocument xDoc = new XmlDocument();

            xDoc.LoadXml(xml);

            List <XmlNode> items = new List <XmlNode>();

            FindAllNodes(xDoc, "item", items);

            List <NewsHeader> headers = new List <NewsHeader>();

            foreach (XmlNode item in items)
            {
                try
                {
                    string description = item.SelectSingleNode("description").InnerText;
                    description = PreDescription(description);

                    NewsHeader header = new NewsHeader(
                        item.SelectSingleNode("title").InnerText,
                        description,
                        item.SelectSingleNode("link").InnerText,
                        rssClass
                        );
                    headers.Add(header);
                }
                catch { }
            }

            return(headers.ToArray());
        }
示例#3
0
        public static NewsBody Parse(NewsHeader header)
        {
            string page = Client.GET(header.Url);

            string content = ArticleParser.Parse(page, header.Url);

            NewsBody body = new NewsBody(header.Title, header.Description, content, header.Class);

            return(body);
        }
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(HttpNotFound("ID is missing"));
            }

            NewsHeader newsHeader = db.NewsHeaders.Find(id);

            if (newsHeader == null)
            {
                return(HttpNotFound("ID was not found"));
            }

            return(View(newsHeader));
        }
示例#5
0
        public NewsHeader GetNewsDetail(long NewsID, string Group = "Full")
        {
            try
            {
                DynamicParameters objParameter = new DynamicParameters();
                objParameter.Add("p_NewsID", NewsID);
                objParameter.Add("p_Group", Group);
                var        result = SqlData.dataContext.QueryMultiple("GetNewsDetails", objParameter, commandType: CommandType.StoredProcedure);
                NewsHeader obj    = result.ReadSingle <NewsHeader>();

                if (obj.NewsID > 0)
                {
                    obj.objNewsContent = result.ReadFirstOrDefault <NewsContent>();
                }

                if (obj.NewsID > 0)
                {
                    obj.objNewsImage = result.ReadFirstOrDefault <NewsImage>();
                }

                if (obj.NewsID > 0)
                {
                    obj.objNewsVideo = result.ReadFirstOrDefault <NewsVideo>();
                }

                //  if (obj.NewsID > 0 && Group == "Full")
                //    obj.objUserInfo = result.ReadFirstOrDefault<UserInfo>();

                return(obj);
            }
            catch (Exception ex)
            {
                throw ex;
                CLoggerDataAccess.WriteLog(ProjectSource.DataAccessLayer, ELogLevel.ERROR, "ERROR ocurred in News Data Access while calling GetNewsDetail Action, Ex.: " + ex.Message);
            }
            return(null);
        }