Пример #1
0
        public ActionResult Create(int eventid)
        {
            Announcement model = new Announcement();

            model.EventID = eventid;
            model.PublishDate = DateTime.Today;

            return View(model);
        }
Пример #2
0
        public ActionResult Create(Announcement announcement)
        {
            try
            {
                service.CreateAnnouncement(new CodeCampService.Announcement
                {
                    EventID = announcement.EventID,
                    Title = announcement.Title,
                    Content = announcement.Content,
                    PublishDate = announcement.PublishDate
                });

                return RedirectToAction("Index");
            }
            catch
            {
                // TODO: show the error

                return View(announcement);
            }
        }
Пример #3
0
        public ActionResult Delete(int id)
        {
            try
            {
                service.DeleteAnnouncement(id);

                return RedirectToAction("Index");
            }
            catch
            {
                var announcement = service.GetAnnouncement(id);

                Announcement model = new Announcement()
                {
                    ID = announcement.ID,
                    EventID = announcement.EventID,
                    Title = announcement.Title,
                    Content = announcement.Content,
                    PublishDate = announcement.PublishDate
                };

                return View("Details", model);
            }
        }
Пример #4
0
        //
        // GET: /Announcement/Details/5
        public ActionResult Details(int id)
        {
            var announcement = service.GetAnnouncement(id);

            Announcement model = new Announcement()
            {
                ID = announcement.ID,
                EventID = announcement.EventID,
                Title = announcement.Title,
                Content = announcement.Content,
                PublishDate = announcement.PublishDate
            };

            return View(model);
        }
Пример #5
0
        public ActionResult Edit(Announcement announcement)
        {
            try
            {
                service.UpdateAnnouncement(new CodeCampService.Announcement
                {
                    ID = announcement.ID,
                    EventID = announcement.EventID,
                    Title = announcement.Title,
                    Content = announcement.Content,
                    PublishDate = announcement.PublishDate
                });

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }