예제 #1
0
        public ActionResult Create(Speaker model)
        {
            try
              {
            var repository = new ObjectRepository<Speaker>();
            if (0 < (repository.Find(s => s.Name == model.Name)).Count())
            {
              throw new WebException("The speaker already exists.");
            }
            model.Id = Guid.NewGuid();
            repository.Save(model);

            return RedirectToAction("Index");
              }
              catch
              {
            return View();
              }
        }
예제 #2
0
        public ActionResult Create(Speaker model)
        {
            try
              {
            var q = (from Speaker o in Db
                 where o.Id == model.Id
                 select o);
            if (0 < q.Count())
            {
              throw new WebException("The speaker already exists.");
            }
            model.Id = Guid.NewGuid();
            Db.Store(model);

            return RedirectToAction("Index");
              }
              catch
              {
            return View();
              }
        }
예제 #3
0
        public ActionResult Edit(Guid id, Speaker speaker)
        {
            try
              {
            var model = (from Speaker o in Db
                     where o.Id == id
                     select o).First();

            model.Name = speaker.Name;
            model.ImageName = speaker.ImageName;
            model.Biography = speaker.Biography;

            Db.Store(model);

            return RedirectToAction("Details", new {speaker.Id});
              }
              catch
              {
            return View();
              }
        }
예제 #4
0
        public ActionResult Edit(Guid id, Speaker speaker)
        {
            try
              {
            var repository = new ObjectRepository<Speaker>();
            repository.Save(speaker);

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