Esempio n. 1
0
        public ActionResult Create(TutorCreate tutor)
        {
            if (!ModelState.IsValid)
            {
                return(View(tutor));
            }
            var svc = CreateTutorService();

            if (svc.CreateTutor(tutor))
            {
                return(RedirectToAction("Index"));
            }
            return(View(tutor));
        }
Esempio n. 2
0
        public bool CreateTutor(TutorCreate tutorCreate)
        {
            var entity = new Tutor
            {
                OwnerId   = _userId,
                FirstName = tutorCreate.FirstName,
                LastName  = tutorCreate.LastName,
                Email     = tutorCreate.Email,
                Rate      = tutorCreate.Rate,
            };

            using (var ctx = new ApplicationDbContext())
            {
                ctx.Tutors.Add(entity);
                return(ctx.SaveChanges() == 1);
            }
        }