コード例 #1
0
        public ActionResult Edit(int id, TalksViewModel model)
        {
            Talks talk = new Talks();

            talk.InjectFrom(model);
            var talkToUpdate = talkService.UpdateTalk(talk);

            return(RedirectToAction(nameof(Index)));
        }
コード例 #2
0
        public ActionResult Edit(int id, TalkViewModel model)
        {
            Talks edit = new Talks();

            edit.InjectFrom(model);
            var createNewTalk = talk.Update(edit);

            return(RedirectToAction(nameof(Index)));
        }
コード例 #3
0
        public ActionResult Create(TalkViewModel model)
        {
            if (ModelState.IsValid)
            {
                Talks newTalk = new Talks();
                newTalk.InjectFrom(model);

                var createTalk = talk.CreateTalk(newTalk);
                if (createTalk == null)
                {
                    ModelState.AddModelError("CompanyName", "Must be unique");
                    return(View(model));
                }
            }
            return(RedirectToAction(nameof(Index)));
        }
コード例 #4
0
        public ActionResult Create(TalksViewModel model)
        {
            if (ModelState.IsValid)
            {
                Talks talk = new Talks();
                talk.InjectFrom(model);
                var createNewTalk = talkService.AddTalk(talk);

                if (createNewTalk == null)
                {
                    ModelState.AddModelError("Name", "The Name must be unique!");

                    return(View(model));
                }
            }
            return(RedirectToAction(nameof(Index)));
        }
コード例 #5
0
        public ActionResult Edit(int id, TalksViewModel model)
        {
            if (ModelState.IsValid)
            {
                Talks talks = new Talks();
                talks.InjectFrom(model);
                var updateTalk = talksService.UpdateATalk(talks);
                if (updateTalk == null)
                {
                    ModelState.AddModelError("Name", "The name must be unique");
                    return(View(model));
                }

                return(RedirectToAction(nameof(Index)));
            }
            else
            {
                return(View(model));
            }
        }