Ejemplo n.º 1
0
        public JsonResult List(int year, int count)
        {
            IDatabaseAccessor dbAccess = new SqlDatabaseAccessor(MvcApplication.GetMockDraftConnectionStringName());

            List <DProspect> dProspects = dbAccess.GetTopProspects(year, count);

            List <WProspect> prospects = new List <WProspect>();

            foreach (var dProspect in dProspects)
            {
                prospects.Add(Mapper.Map <WProspect>(dProspect));
            }

            return(new JsonResult
            {
                Data = prospects,
                JsonRequestBehavior = JsonRequestBehavior.AllowGet
            });
        }
        public ActionResult Create(CreateLeagueModel createLeagueModel)
        {
            var league = createLeagueModel.LeagueModel;

            var dLeague          = Mapper.Map <DLeague>(league);
            IDatabaseAccessor db = new SqlDatabaseAccessor(MvcApplication.GetMockDraftConnectionStringName());

            if (ModelState.IsValid)
            {
                if (db.LeagueNameExists(league.Name))
                {
                    ViewBag.Feedback = createLeagueModel.AlreadyExistedErrorMessage;
                    return(View(createLeagueModel));
                }

                db.AddLeague(dLeague);
                ViewBag.Feedback = createLeagueModel.SuccessMessage;
            }

            return(View());
        }
Ejemplo n.º 3
0
        public ActionResult Create(CreateProspectModel createProspectModel)
        {
            var prospectModel = createProspectModel.ProspectModel;

            prospectModel.Team = GetTeamWithId(createProspectModel.TeamId, createProspectModel.PossibleTeams);
            var dProspect        = Mapper.Map <DProspect>(prospectModel);
            IDatabaseAccessor db = new SqlDatabaseAccessor(MvcApplication.GetMockDraftConnectionStringName());

            if (ModelState.IsValid)
            {
                if (db.ProspectExists(dProspect))
                {
                    ViewBag.Feedback = createProspectModel.AlreadyExistedErrorMessage;
                    return(View(createProspectModel));
                }

                db.AddProspect(dProspect);
                ViewBag.Feedback = createProspectModel.SuccessMessage;
            }

            var newProspectModel = new CreateProspectModel();

            return(View(newProspectModel));
        }
Ejemplo n.º 4
0
        public ActionResult Create(CreateTeamModel createTeamModel)
        {
            var teamModel = createTeamModel.TeamModel;

            teamModel.League = GetLeagueWithId(createTeamModel.LeagueId, createTeamModel.PossibleLeagues);
            var dTeam            = Mapper.Map <DTeam>(teamModel);
            IDatabaseAccessor db = new SqlDatabaseAccessor(MvcApplication.GetMockDraftConnectionStringName());

            if (ModelState.IsValid)
            {
                if (db.TeamExists(dTeam))
                {
                    ViewBag.Feedback = createTeamModel.AlreadyExistedErrorMessage;
                    return(View(createTeamModel));
                }

                db.AddTeam(dTeam);
                ViewBag.Feedback = createTeamModel.SuccessMessage;
            }

            var newTeamModel = new CreateTeamModel();

            return(View(newTeamModel));
        }