public void Update(Player player)
        {
            var playerModified = _mapper.Map <Players>(player);

            _ctx.Players.Attach(playerModified);
            _ctx.Entry(playerModified).State = EntityState.Modified;
        }
        public void Update(Tournament tournament)
        {
            var tournamentModified = _mapper.Map <Tournaments>(tournament);

            _ctx.Tournaments.Attach(tournamentModified);
            _ctx.Entry(tournamentModified).State = EntityState.Modified;
        }
Example #3
0
        public void Update(Match match)
        {
            var matchModified = _mapper.Map <Matches>(match);

            _ctx.Matches.Attach(matchModified);
            _ctx.Entry(matchModified).State = EntityState.Modified;
        }
        public void Update(Position position)
        {
            var positionModified = _mapper.Map <Positions>(position);

            _ctx.Positions.Attach(positionModified);
            _ctx.Entry(positionModified).State = EntityState.Modified;
        }
Example #5
0
        public ActionResult EnrollStudent(String programmeName)
        {
            String user = User.Identity.Name;

            ViewData["userName"] = user;
            Student st = db.Students.Find(user);

            st.IsEnrolled = true;

            db.Entry(st).State = EntityState.Modified;
            db.SaveChanges();
            ViewData["isEnrolled"] = true;

            QueryManager           manager  = new QueryManager(db);
            List <FacultyRankList> rankList = manager.getStudentRankList(user);

            foreach (var item in rankList)
            {
                if (item.ProgrammeName != programmeName)
                {
                    db.FacultyRankLists.Attach(item);
                    db.FacultyRankLists.Remove(item);
                    db.SaveChanges();
                }
            }


            //return RedirectToAction("Index", "StudentRankingInformation");
            var redirectUrl = new UrlHelper(Request.RequestContext).Action("Index", "StudentRankingInformation");

            return(Json(new { Url = redirectUrl }));
        }
        public void Update(Goalscorer goalscorer)
        {
            var goalscorerModified = _mapper.Map <Goalscorers>(goalscorer);

            _ctx.Goalscorers.Attach(goalscorerModified);
            _ctx.Entry(goalscorerModified).State = EntityState.Modified;
        }
 public ActionResult Edit(Exam exam)
 {
     if (ModelState.IsValid)
     {
         db.Entry(exam).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(exam));
 }
Example #8
0
        public ActionResult algoStart()
        {
            //Algo start
            Ranker ranker = new Ranker(db);

            ranker.start();

            RankingDates dates = db.Dates.ToList().Last();


            if (dates.FirstRankingDate == "false")
            {
                dates.FirstRankingDate = "true";
                db.Entry(dates).State  = EntityState.Modified;
                db.SaveChanges();
            }
            else
            {
                if (dates.FirstRankingDate == "true" && dates.SecondRankingDate == "false")
                {
                    dates.SecondRankingDate = "true";
                    db.Entry(dates).State   = EntityState.Modified;
                    db.SaveChanges();
                }
                else
                {
                    if (dates.SecondRankingDate == "true" && dates.ThirdRankingDate == "false")
                    {
                        dates.ThirdRankingDate = "true";
                        db.Entry(dates).State  = EntityState.Modified;
                        db.SaveChanges();
                    }
                }
            }


            //return RedirectToAction("Index", "StudentRankingInformation");
            var redirectUrl = new UrlHelper(Request.RequestContext).Action("Index", "ProgrammeRankList");

            return(Json(new { Url = redirectUrl }));
        }
Example #9
0
        public TeamStat GetOrCreateByTeam(int teamId)
        {
            var teamStat = _ctx.TeamStats.AsNoTracking()
                           .FirstOrDefault(e => e.TeamID == teamId);

            if (teamStat == null)
            {
                var teamStatToAdd = new TeamStats
                {
                    TeamID = teamId
                };

                var createdTeamStat = _ctx.TeamStats.Add(teamStatToAdd);
                _ctx.SaveChanges();
                _ctx.Entry(teamStatToAdd).State = EntityState.Detached;

                teamStat = _ctx.TeamStats.AsNoTracking()
                           .FirstOrDefault(e => e.TeamID == teamId);
            }

            return(_mapper.Map <TeamStat>(teamStat));
        }
Example #10
0
        public Head2HeadWorldCup GetOrCreateByTeams(int team1Id, int team2Id)
        {
            var h2h = _ctx.H2HWorldCup.AsNoTracking()
                      .FirstOrDefault(e => e.Team1ID == team1Id && e.Team2ID == team2Id);

            if (h2h == null)
            {
                var h2hToAdd = new H2HWorldCup
                {
                    Team1ID = team1Id,
                    Team2ID = team2Id
                };

                var createdH2H = _ctx.H2HWorldCup.Add(h2hToAdd);
                _ctx.SaveChanges();
                _ctx.Entry(h2hToAdd).State = EntityState.Detached;

                h2h = _ctx.H2HWorldCup.AsNoTracking()
                      .FirstOrDefault(e => e.Team1ID == team1Id && e.Team2ID == team2Id);
            }

            return(_mapper.Map <Head2HeadWorldCup>(h2h));
        }
Example #11
0
        private bool SaveData()
        {
            if (currentMark.Id == 0)
            {
                _context.Marks.Add(currentMark);
            }
            else
            {
                _context.Entry(currentMark).State = System.Data.Entity.EntityState.Modified;
            }

            _context.SaveChanges();
            return(true);
        }
Example #12
0
        public void grade(String studentEGN, List <Preference> preferences)
        {
            grades = queryManager.getStudentGrades(studentEGN);

            //TODO: Should we check for exams with the same name but different date?

            foreach (Preference preference in preferences)
            {
                preference.TotalGrade = calculateTotalGrade(studentEGN, preference.ProgrammeName);

                //add total grade in preference table
                context.Preferences.Attach(preference);
                context.Entry(preference).Property(x => x.TotalGrade).IsModified = true;
                context.SaveChanges();
            }
        }
        public void SaveCounts(int maleCount, int femaleCount, string programmeName)
        {
            //ako crashnat int-ovete napravi si go sys string parametri
            var rule = db.ProgrammesRules.Find(programmeName);

            if (rule == null)
            {
                db.ProgrammesRules.Add(new ProgrammeRules()
                {
                    FemaleCount   = femaleCount,
                    MaleCount     = maleCount,
                    ProgrammeName = programmeName
                });
                db.SaveChanges();
                return;
            }
            rule.MaleCount       = maleCount;
            rule.FemaleCount     = femaleCount;
            db.Entry(rule).State = EntityState.Modified;
            db.SaveChanges();
        }
Example #14
0
 public void Update(MatchType matchType)
 {
     Entities.MatchTypes matchTypeUpdated = _mapper.Map <Entities.MatchTypes>(matchType);
     _ctx.MatchTypes.Attach(matchTypeUpdated);
     _ctx.Entry(matchTypeUpdated).State = EntityState.Modified;
 }
 public void Update(Domain.Ranking ranking)
 {
     Entities.Rankings rankingUpdated = _mapper.Map <Entities.Rankings>(ranking);
     _ctx.Rankings.Attach(rankingUpdated);
     _ctx.Entry(rankingUpdated).State = EntityState.Modified;
 }
Example #16
0
 public void Update(Team team)
 {
     Entities.Teams teamUpdated = _mapper.Map <Entities.Teams>(team);
     _ctx.Teams.Attach(teamUpdated);
     _ctx.Entry(teamUpdated).State = EntityState.Modified;
 }
Example #17
0
 public void Update(Confederation confederation)
 {
     Entities.Confederations confederationUpdated = _mapper.Map <Entities.Confederations>(confederation);
     _ctx.Confederations.Attach(confederationUpdated);
     _ctx.Entry(confederationUpdated).State = EntityState.Modified;
 }