Esempio n. 1
0
        public HttpResponseMessage Post(int compId, string userName, [FromBody] TblCompetitorsClimb value)
        {
            value.Paid          = false;
            value.CompetitionId = compId;
            string accountId = CompetitionDB.Users.FirstOrDefault(x => x.UserName == userName).Id;

            value.UserId = CompetitionDB.TblUsers.FirstOrDefault(x => x.UserId == accountId).Id;
            value.Paid   = false;
            CompetitionDB.TblCompetitorsClim.Add(value);
            CompetitionDB.SaveChanges();
            List <RouteClimbModel> routes = CompetitionDB.TblRoutesClim.ToArray().Where(x => x.CompetitionId == compId && x.Type == "ATRANKA").Select(x => new RouteClimbModel(x)).ToList();
            TblJudgesPaperClim     paper  = new TblJudgesPaperClim();

            foreach (RouteClimbModel r in routes)
            {
                paper.JudgeId      = 0;
                paper.RouteId      = r.Id;
                paper.TopAttempt   = 0;
                paper.BonusAttempt = 0;
                paper.ClimberId    = CompetitionDB.TblUsers.FirstOrDefault(x => x.UserId == accountId).Id;
                paper.Date         = DateTime.Now;
                paper.TypeId       = 0;
                CompetitionDB.TblJudgesPapersClimb.Add(paper);
                CompetitionDB.SaveChanges();
            }

            return(ToJsonCreated(CompetitionDB.SaveChanges()));
        }
 public JudgesPaperClimbModel(TblJudgesPaperClim row)
 {
     Id           = row.Id;
     TopAttempt   = row.TopAttempt;
     BonusAttempt = row.BonusAttempt;
     Date         = row.Date;
     PaperTypeId  = row.TypeId;
     RouteId      = row.RouteId;
 }
Esempio n. 3
0
        public HttpResponseMessage Put(int routeId, int userId, int n)
        {
            if (CompetitionDB.TblJudgesPapersClimb.FirstOrDefault(x => x.ClimberId == userId && x.RouteId == routeId) != null)
            {
                TblJudgesPaperClim paper = CompetitionDB.TblJudgesPapersClimb.FirstOrDefault(x => x.ClimberId == userId && x.RouteId == routeId);
                switch (n)
                {
                case 1:
                    paper.TopAttempt = 1;
                    break;

                case 2:
                    paper.TopAttempt = 2;
                    break;

                case 3:
                    paper.BonusAttempt = 1;
                    break;

                case 4:
                    paper.TopAttempt++;
                    break;

                case 5:
                    paper.TopAttempt--;
                    break;

                case 6:
                    paper.BonusAttempt++;
                    break;

                case 7:
                    paper.BonusAttempt--;
                    break;
                }
                paper.Date = DateTime.Now;

                CompetitionDB.Entry(paper).State = EntityState.Modified;

                return(ToJsonOK(CompetitionDB.SaveChanges()));
            }

            return(ToJsonNotFound("Objektas nerastas."));
        }
Esempio n. 4
0
        public HttpResponseMessage Post(int compId, int id)
        {
            TblCompetitorsClimb value = new TblCompetitorsClimb();

            value.Paid          = false;
            value.CompetitionId = compId;
            value.UserId        = id;
            int dateYear = 0;
            int dateNow  = 0;

            if (CompetitionDB.TblUsers.Find(id).BirthYear.ToString().Length == 22)
            {
                dateYear = Convert.ToInt32(CompetitionDB.TblUsers.Find(id).BirthYear.ToString().Substring(6, 4));
            }
            else if (CompetitionDB.TblUsers.Find(id).BirthYear.ToString().Length == 20)
            {
                dateYear = Convert.ToInt32(CompetitionDB.TblUsers.Find(id).BirthYear.ToString().Substring(4, 4));
            }
            else
            {
                dateYear = Convert.ToInt32(CompetitionDB.TblUsers.Find(id).BirthYear.ToString().Substring(5, 4));
            }

            if (DateTime.Now.ToString().Length == 22)
            {
                dateNow = Convert.ToInt32(DateTime.Now.ToString().Substring(6, 4));
            }
            else if (DateTime.Now.ToString().Length == 20)
            {
                dateNow = Convert.ToInt32(DateTime.Now.ToString().Substring(4, 4));
            }
            else if (DateTime.Now.ToString().Length == 21)
            {
                dateNow = Convert.ToInt32(DateTime.Now.ToString().Substring(5, 4));
            }

            if ((dateNow - dateYear) > 17)
            {
                value.Group = "JAUNIMAS";
            }
            else if ((dateNow - dateYear) > 15)
            {
                value.Group = "JAUNIAI";
            }
            else if ((dateNow - dateYear) > 13)
            {
                value.Group = "JAUNUOLIAI";
            }
            else if ((dateNow - dateYear) > 11)
            {
                value.Group = "JAUNUČIAI";
            }
            else
            {
                value.Group = "VAIKAI";
            }

            CompetitionDB.TblCompetitorsClim.Add(value);

            List <RouteClimbModel> routes = CompetitionDB.TblRoutesClim.ToArray().Where(x => x.CompetitionId == compId && x.Type == value.Group).Select(x => new RouteClimbModel(x)).ToList();
            TblJudgesPaperClim     paper  = new TblJudgesPaperClim();

            foreach (RouteClimbModel r in routes)
            {
                paper.JudgeId      = 0;
                paper.RouteId      = r.Id;
                paper.TopAttempt   = 0;
                paper.BonusAttempt = 0;
                paper.ClimberId    = id;
                paper.Date         = DateTime.Now;
                paper.TypeId       = 0;
                CompetitionDB.TblJudgesPapersClimb.Add(paper);
                CompetitionDB.SaveChanges();
            }
            return(ToJsonCreated(CompetitionDB.SaveChanges()));
        }