public bool CreateCoach(CoachCreate model)
        {
            var entity =
                new Coaches
            {
                FirstName     = model.FirstName,
                LastName      = model.LastName,
                PositionCoach = model.PositionCoach,
            };

            using (var ctx = new ApplicationDbContext())
            {
                ctx.Coaches.Add(entity);
                return(ctx.SaveChanges() == 1);
            }
        }
        public IHttpActionResult Coach(CoachCreate coach)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var service = CreateCoachService();

            if (!service.CreateCoach(coach))
            {
                return(InternalServerError());
            }

            return(Ok());
        }
        public ActionResult Create(CoachCreate model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            var service = CreateCoachService();

            if (service.CreateCoach(model))
            {
                TempData["SaveResult"] = "your coach was added to the staff";
                return(RedirectToAction("Index"));
            }
            ;
            return(View(model));
        }
        public bool CreateCoach(CoachCreate model)
        {
            var entity =
                new Coach()
            {
                CoachName          = model.CoachName,
                SeasonRecord       = model.SeasonRecord,
                OverallRecord      = model.OverallRecord,
                MarchMadnessRecord = model.MarchMadnessRecord,
                TeamId             = model.TeamId,
            };

            using (var ctx = new ApplicationDbContext())
            {
                ctx.Coach.Add(entity);
                return(ctx.SaveChanges() == 1);
            }
        }
Exemplo n.º 5
0
        public bool CreateCoach(CoachCreate model)
        {
            var entity =
                new Coach()
            {
                OwnerId   = _userId,
                FirstName = model.FirstName,
                LastName  = model.LastName,
                Email     = model.Email,
                TeamId    = model.TeamId
            };

            using (var ctx = new ApplicationDbContext())
            {
                ctx.Coaches.Add(entity);
                return(ctx.SaveChanges() == 1);
            }
        }
Exemplo n.º 6
0
        public ActionResult Create(CoachCreate model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }


            var service = CreateCoachService();

            if (service.CreateCoach(model))
            {
                TempData["SaveResult"] = "Your Coach was created.";
                return(RedirectToAction("Index"));
            }
            ;

            ModelState.AddModelError("", "Coach could not be created.");

            return(View(model));
        }