Пример #1
0
        //Create new tutor
        public bool CreateTutor(CreateTutor model)
        {
            var entity =
                new Tutor()
            {
                FirstName = model.TutorFirstName,
                LastName  = model.TutorLastName,
                Location  = model.TutorLocation
            };

            using (var ctx = new ApplicationDbContext())
            {
                ctx.Tutors.Add(entity);
                return(ctx.SaveChanges() > 0);
            }
        }
Пример #2
0
        public ActionResult Create(CreateTutor model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            var service = CreateTutorService();

            if (service.CreateTutor(model))
            {
                TempData["SaveResult"] = "A tutor was added.";
                return(RedirectToAction("Index"));
            }
            ModelState.AddModelError("", "A tutor could not be added.");
            return(View(model));
        }