예제 #1
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");
        }
예제 #2
0
        public ActionResult EventsDelete(EventsEditViewModel delete_events)
        {
            var events = db.Events.Find(delete_events.Id);
            
            db.Events.Remove(events);
            db.SaveChanges();

            return RedirectToAction("Events");
        }
예제 #3
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");
        }
예제 #4
0
        public ActionResult EventsDeleteConfirm(int id)
        {
            var events = db.Events.Find(id);

            EventsEditViewModel _events = new EventsEditViewModel
            {
                Id = events.ID,
                Title = events.Title,
                Content = events.Content,
                ImagePath = events.ImageUrl
            };
            return View(_events);
        }
예제 #5
0
        public ActionResult EventsEdit(int id)
        {
            var events = db.Events.Find(id);

            var image = new UploadImageModel()
            {
                InstanceId = events.ID,
                ParentId = events.ID,
                IsPrimary = false,
                CurrentImage = null,
                Type = "events"
            };

            EventsEditViewModel _events = new EventsEditViewModel
            {
                Image = image,
                Title = events.Title,
                Content = events.Content,
                Id = events.ID,
                ImagePath = events.ImageUrl
            };

            return View(_events);
        }