Exemplo n.º 1
0
        public bool CreateTalk(TalkCreate model)
        {
            var entity =
                new Talk()
            {
                Name          = model.Name,
                Description   = model.Description,
                Topic         = model.Topic,
                TeacherId     = model.TeacherId,
                TalkLength    = model.TalkLength,
                TalkDate      = model.TalkDate,
                IsGuided      = model.IsGuided,
                RetreatId     = model.RetreatId,
                CenterId      = model.CenterId,
                TeacherLinkId = model.TeacherLinkId,
                TalkLinkId    = model.TalkLinkId,
                //TalkLink=model.TalkLink
            };

            using (var ctx = new ApplicationDbContext())
            {
                ctx.Talks.Add(entity);
                return(ctx.SaveChanges() == 1);
            }
        }
Exemplo n.º 2
0
        public ActionResult Create(TalkCreate model)
        {
            // TODO: Add insert logic here
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var service = CreateTalkService();

            if (service.CreateTalk(model))
            {
                TempData["SaveResult"] = "Your talk was created.";
                return(RedirectToAction("Index"));
            }
            ModelState.AddModelError("", "Talk could not be created.");
            return(View(model));
        }