Beispiel #1
0
        public ActionResult addNews(string title, string description, string tag, HttpPostedFileBase file, string city)
        {
            if (!isLogin())
            {
                return(RedirectToAction("Login", "Author"));
            }
            NewsServiceClient ins = new NewsServiceClient();
            News n = new News();

            //Author a = ins.getAuthor((int)Session["authorid"]);
            n.title       = title;
            n.description = description;
            n.tag         = tag;
            n.newsCity    = city;
            System.Diagnostics.Debug.WriteLine("ok rokad" + (int)Session["authorid"]);
            Author a = new Author();

            a.authorId = (int)Session["authorid"];
            n.author   = a;
            if (file != null)
            {
                n.image = file.FileName;
                var fileBytes = new byte[file.ContentLength];
                file.InputStream.Read(fileBytes, 0, fileBytes.Length);
                n.imagedata = fileBytes;
            }
            else
            {
                n.image     = null;
                n.imagedata = null;
            }
            int newsid = ins.addNews(n);

            return(RedirectToAction("getAllNews", "News"));
        }