Example #1
0
        public ActionResult NewsSubmit(NewsEditViewModel submit_news)
        {
            var news = db.News.SingleOrDefault(r => r.ID == submit_news.Id);

            news.Title = submit_news.Title;
            news.Content = submit_news.Content;

            db.SaveChanges();

            ImageUpload _upload = new ImageUpload(Server);
            _upload.UploadImage(submit_news.Image);

            return RedirectToAction("News");
        }
Example #2
0
        public ActionResult EventsSubmit(EventsEditViewModel submit_events)
        {
            var events = db.Events.Find(submit_events.Id);
            
            events.Title = submit_events.Title;
            events.Content = submit_events.Content;

            db.SaveChanges();

            ImageUpload _upload = new ImageUpload(Server);
            _upload.UploadImage(submit_events.Image);

            return RedirectToAction("Events");
        }
Example #3
0
        public ActionResult EventsCreateSubmit(EventsEditViewModel create_events)
        {
            Events events = new Events 
            {
                Title = create_events.Title,
                Content = create_events.Content,
                CreateDate = DateTime.Now
            };

            db.Events.Add(events);
            db.SaveChanges();

            ImageUpload _upload = new ImageUpload(Server);

            create_events.Image.Type = "events";
            create_events.Image.InstanceId = events.ID;
            create_events.Image.ParentId = events.ID;

            _upload.UploadImage(create_events.Image);

            return RedirectToAction("Events");
        }
Example #4
0
        public ActionResult CreateSubmit(NewsEditViewModel create_news)
        {
             
            News CreateNews = new News
            {
            Title = create_news.Title,
            Content = create_news.Content,
            CreateDate = DateTime.Now,
             };

            db.News.Add(CreateNews);
            db.SaveChanges();

            

            ImageUpload _upload = new ImageUpload(Server);

            create_news.Image.Type = "news";
            create_news.Image.InstanceId = CreateNews.ID;
            create_news.Image.ParentId = CreateNews.ID;

            _upload.UploadImage(create_news.Image);

            return RedirectToAction("News");
        }