Example #1
0
        /** Pakoreguojama bauda;
         * galima koreguoti baudą, kuri yra duomenų bazėje ir yra Penalty.Yra == true*/
        public HttpResponseMessage Put(int id, [FromBody] TblPenalty value)
        {
            value.Yra = true;
            CompetitionDB.Entry(value).State = EntityState.Modified;

            return(ToJsonOK(CompetitionDB.SaveChanges()));
        }
Example #2
0
        public HttpResponseMessage Put(int id, [FromBody] TblJudgesPaperKKT value)
        {
            value.Date = DateTime.Now;

            CompetitionDB.Entry(value).State = EntityState.Modified;
            return(ToJsonOK(CompetitionDB.SaveChanges()));
        }
Example #3
0
        public HttpResponseMessage Post(string userName, [FromBody] TblUser value, int n)
        {
            string accountId = CompetitionDB.Users.FirstOrDefault(x => x.UserName == userName).Id;
            int    id        = CompetitionDB.TblUsers.FirstOrDefault(x => x.UserId == accountId).Id;

            TblUser user = new TblUser();

            user.Name      = value.Name;
            user.LastName  = value.LastName;
            user.BirthYear = value.BirthYear;
            user.Lytis     = value.Lytis;
            user.Active    = true;
            user.UserId    = "0";
            user.TrainerId = id;
            user.ClubId    = CompetitionDB.TblUsers.Find(id).ClubId;
            user.Email     = "";
            user.TelNumber = "";
            user.TeamId    = 0;
            CompetitionDB.TblUsers.Add(user);
            CompetitionDB.SaveChanges();
            int         idUser = CompetitionDB.TblUsers.FirstOrDefault(x => x.Name == user.Name && x.LastName == user.LastName).Id;
            TblUserRole role   = new TblUserRole();

            //Pridedama "NEPILNAMEČIO DALYVIO" rolė
            role.RoleId = 6;
            role.UserId = idUser;
            CompetitionDB.TblUserRoles.Add(role);

            return(ToJsonCreated(CompetitionDB.SaveChanges()));
        }
Example #4
0
        public HttpResponseMessage Post(int compId, string userName, [FromBody] TblCompetitorsKKT value)
        {
            value.Paid          = false;
            value.CompetitionId = compId;
            string accountId = CompetitionDB.Users.FirstOrDefault(x => x.UserName == userName).Id;
            int    Id        = CompetitionDB.TblUsers.FirstOrDefault(x => x.UserId == accountId).Id;

            value.TeamId = CompetitionDB.TblUsers.FirstOrDefault(x => x.UserId == accountId).TeamId;
            value.Paid   = false;
            CompetitionDB.TblCompetitorsKKT.Add(value);
            CompetitionDB.SaveChanges();
            List <RouteKKTModel> routes = CompetitionDB.TblRoutesKKT.ToArray().Where(x => x.CompetitionId == compId && x.Type == value.Group).Select(x => new RouteKKTModel(x)).ToList();
            TblJudgesPaperKKT    paper  = new TblJudgesPaperKKT();

            foreach (RouteKKTModel r in routes)
            {
                paper.JudgeId = 0;
                paper.RouteId = r.Id;
                paper.Time    = "00:00:00";
                paper.Comment = "";
                paper.Date    = DateTime.Now;
                paper.TypeId  = 0;
                paper.UserId  = value.TeamId;
                CompetitionDB.TblJudgesPapersKKT.Add(paper);
                CompetitionDB.SaveChanges();
            }

            return(ToJsonCreated(CompetitionDB.SaveChanges()));
        }
Example #5
0
        /** Pridedama nauja bauda*/
        public HttpResponseMessage Post([FromBody] TblPenalty value)
        {
            value.Yra = true;
            CompetitionDB.TblPenalties.Add(value);

            return(ToJsonCreated(CompetitionDB.SaveChanges()));
        }
Example #6
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()));
        }
Example #7
0
        public HttpResponseMessage Put(int userId, int teamId)
        {
            TblUser user = CompetitionDB.TblUsers.Find(userId);

            user.TeamId = teamId;
            CompetitionDB.Entry(user).State = EntityState.Modified;

            return(ToJsonOK(CompetitionDB.SaveChanges()));
        }
Example #8
0
        public HttpResponseMessage Put(int id)
        {
            TblCompetitorsKKT value = CompetitionDB.TblCompetitorsKKT.Find(id);

            value.Paid = true;
            CompetitionDB.Entry(value).State = EntityState.Modified;

            return(ToJsonOK(CompetitionDB.SaveChanges()));
        }
Example #9
0
 public HttpResponseMessage Delete(int penaltyId)
 {
     if (CompetitionDB.TblPenaltyQuantities.FirstOrDefault(x => x.Id == penaltyId) != null)
     {
         CompetitionDB.TblPenaltyQuantities.Remove(CompetitionDB.TblPenaltyQuantities.FirstOrDefault(x => x.Id == penaltyId));
         return(ToJsonOK(CompetitionDB.SaveChanges()));
     }
     return(ToJsonNotFound("Objektas nerastas."));
 }
Example #10
0
        public HttpResponseMessage Post(string user, [FromBody] TblTeam value)
        {
            string accountId = CompetitionDB.Users.FirstOrDefault(x => x.UserName == user).Id;
            int    id        = CompetitionDB.TblUsers.FirstOrDefault(x => x.UserId == accountId).Id;

            value.TeamCaptainId = id;
            CompetitionDB.TblTeams.Add(value);

            return(ToJsonCreated(CompetitionDB.SaveChanges()));
        }
Example #11
0
        public HttpResponseMessage Post(int compId, int id)
        {
            TblCompJudge value = new TblCompJudge();

            value.CompId = compId;
            value.UserId = id;
            CompetitionDB.TblCompJudges.Add(value);

            return(ToJsonCreated(CompetitionDB.SaveChanges()));
        }
Example #12
0
        public HttpResponseMessage Delete(int compid, int id)
        {
            if (CompetitionDB.TblCompetitorsKKT.FirstOrDefault(x => x.TeamId == id && x.CompetitionId == compid) != null)
            {
                CompetitionDB.TblCompetitorsKKT.Remove(CompetitionDB.TblCompetitorsKKT.FirstOrDefault(x => x.TeamId == id && x.CompetitionId == compid));
                return(ToJsonOK(CompetitionDB.SaveChanges()));
            }

            return(ToJsonNotFound("Objektas nerastas."));
        }
Example #13
0
        public HttpResponseMessage Post([FromBody] TblTeam value)
        {
            CompetitionDB.TblTeams.Add(value);
            CompetitionDB.SaveChanges();
            TblUser user = CompetitionDB.TblUsers.Find(value.TeamCaptainId);

            user.TeamId = value.Id;
            CompetitionDB.Entry(user).State = EntityState.Modified;

            return(ToJsonCreated(CompetitionDB.SaveChanges()));
        }
Example #14
0
        public HttpResponseMessage Post(int paperId, int penaltyId)
        {
            TblPenaltyQuantity value = new TblPenaltyQuantity();

            value.JudgesPaperId = paperId;
            value.PenaltyId     = penaltyId;
            value.Quantity      = 1;

            CompetitionDB.TblPenaltyQuantities.Add(value);
            return(ToJsonOK(CompetitionDB.SaveChanges()));
        }
Example #15
0
        /** Fiktyvus Delete metodas;
         * Bauda padarome neaktyve;
         * Penalty.Yra == false;
         * Tai galima padaryti tik daudai, kuri  yra duomenų bazėje ir yra Penalty.Yra == true*/
        public HttpResponseMessage Delete(int id)
        {
            if (CompetitionDB.TblPenalties.FirstOrDefault(x => x.Id == id) != null)
            {
                TblPenalty penalty = CompetitionDB.TblPenalties.FirstOrDefault(x => x.Id == id);
                penalty.Yra = false;
                CompetitionDB.Entry(penalty).State = EntityState.Modified;
                return(ToJsonOK(CompetitionDB.SaveChanges()));
            }

            return(ToJsonNotFound("Objektas nerastas."));
        }
Example #16
0
        public HttpResponseMessage Put(int routeId, [FromBody] TblRouteKKT value)
        {
            /* if (CompetitionDB.TblRoutesKKT.FirstOrDefault(x => x.Id == routeId) != null)
             * {*/
            CompetitionDB.Entry(value).State = EntityState.Modified;

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

            /* }
             *
             * return ToJsonNotFound("Objektas nerastas.");*/
        }
Example #17
0
        public HttpResponseMessage Delete(int id)
        {
            if (CompetitionDB.TblUsers.FirstOrDefault(x => x.Id == id && x.Active == true) != null)
            {
                TblUser user = CompetitionDB.TblUsers.FirstOrDefault(x => x.Id == id);
                user.Active = false;
                CompetitionDB.Entry(user).State = EntityState.Modified;
                return(ToJsonOK(CompetitionDB.SaveChanges()));
            }

            return(ToJsonNotFound("Objektas nerastas."));
        }
Example #18
0
        public HttpResponseMessage Delete(int id)
        {
            if (CompetitionDB.TblCompetitorsKKT.FirstOrDefault(x => x.Id == id) != null)
            {
                int UserId = CompetitionDB.TblCompetitorsKKT.FirstOrDefault(x => x.Id == id).TeamId;
                int CompId = CompetitionDB.TblCompetitorsKKT.FirstOrDefault(x => x.Id == id).CompetitionId;
                CompetitionDB.TblCompetitorsKKT.Remove(CompetitionDB.TblCompetitorsKKT.FirstOrDefault(x => x.Id == id));
                // CompetitionDB.SaveChanges();


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

            return(ToJsonNotFound("Objektas nerastas."));
        }
Example #19
0
        public HttpResponseMessage Put(int id, string trainerName, [FromBody] TblUser value)
        {
            string accountId = CompetitionDB.Users.FirstOrDefault(x => x.UserName == trainerName).Id;
            int    trainerId = CompetitionDB.TblUsers.FirstOrDefault(x => x.UserId == accountId).Id;

            value.TrainerId = trainerId;
            value.TelNumber = "";
            value.Email     = "";
            value.UserId    = "0";
            value.Active    = true;
            value.ClubId    = CompetitionDB.TblUsers.Find(trainerId).ClubId;
            value.TeamId    = CompetitionDB.TblUsers.Find(id).TeamId;
            CompetitionDB.Entry(value).State = EntityState.Modified;

            return(ToJsonOK(CompetitionDB.SaveChanges()));
        }
Example #20
0
        public HttpResponseMessage Post(string userName, [FromBody] TblUser user)
        {
            string accountId = CompetitionDB.Users.FirstOrDefault(x => x.UserName == userName).Id;

            user.UserId = accountId;
            user.Active = true;
            CompetitionDB.TblUsers.Add(user);
            CompetitionDB.SaveChanges();
            int         id   = CompetitionDB.TblUsers.FirstOrDefault(x => x.UserId == accountId).Id;
            TblUserRole role = new TblUserRole();

            role.RoleId = 1;
            role.UserId = id;
            CompetitionDB.TblUserRoles.Add(role);

            return(ToJsonCreated(CompetitionDB.SaveChanges()));
        }
Example #21
0
        public HttpResponseMessage Put(int penaltyId, int n)
        {
            TblPenaltyQuantity value = CompetitionDB.TblPenaltyQuantities.Find(penaltyId);

            switch (n)
            {
            case 1:
                value.Quantity++;
                break;

            case 2:
                value.Quantity--;
                break;
            }

            CompetitionDB.Entry(value).State = EntityState.Modified;
            return(ToJsonOK(CompetitionDB.SaveChanges()));
        }
Example #22
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."));
        }
Example #23
0
        public HttpResponseMessage Post([FromBody] TblRouteKKT value)
        {
            CompetitionDB.TblRoutesKKT.Add(value);

            return(ToJsonCreated(CompetitionDB.SaveChanges()));
        }
        public HttpResponseMessage Post(string userName, [FromBody] TblCompetition value)
        {
            string accountId = CompetitionDB.Users.FirstOrDefault(x => x.UserName == userName).Id;
            int    id        = CompetitionDB.TblUsers.FirstOrDefault(x => x.UserId == accountId).Id;

            value.OrgId  = id;
            value.Open   = true;
            value.Update = true;
            CompetitionDB.TblCompetitions.Add(value);

            /** Sukuriamos trasos LAIPIOJIMO VARŽYBOMS*/
            if (value.Type)
            {
                CompetitionDB.SaveChanges();

                int compId = CompetitionDB.TblCompetitions.First(x => x.Name == value.Name && x.Date == value.Date).Id;

                TblRouteClimb route = new TblRouteClimb();
                if (value.ClimbType == 1)
                {
                    int i;
                    int p = 2;

                    for (i = 0; i < 6; i++)
                    {
                        route.Number        = i + 1;
                        route.PointsFlash   = p + (p / 2);
                        route.PointsTop     = p;
                        route.PointsBonus   = p / 2;
                        route.Type          = "ATRANKA";
                        route.CompetitionId = compId;
                        p += 2;
                        CompetitionDB.TblRoutesClim.Add(route);
                        CompetitionDB.SaveChanges();
                    }
                }
                else if (value.ClimbType == 2)
                {
                    int i;
                    for (i = 0; i < 6; i++)
                    {
                        route.Number        = i + 1;
                        route.PointsFlash   = 1;
                        route.PointsTop     = 1;
                        route.PointsBonus   = 1;
                        route.Type          = "ATRANKA";
                        route.CompetitionId = compId;
                        CompetitionDB.TblRoutesClim.Add(route);
                        CompetitionDB.SaveChanges();
                    }
                }
                else
                {
                    int i;
                    for (i = 0; i < 4; i++)
                    {
                        route.Number        = i + 1;
                        route.PointsFlash   = 1;
                        route.PointsTop     = 1;
                        route.PointsBonus   = 1;
                        route.Type          = "JAUNIMAS";
                        route.CompetitionId = compId;
                        CompetitionDB.TblRoutesClim.Add(route);
                        CompetitionDB.SaveChanges();
                    }

                    for (i = 0; i < 4; i++)
                    {
                        route.Number        = i + 1;
                        route.PointsFlash   = 1;
                        route.PointsTop     = 1;
                        route.PointsBonus   = 1;
                        route.Type          = "JAUNIAI";
                        route.CompetitionId = compId;
                        CompetitionDB.TblRoutesClim.Add(route);
                        CompetitionDB.SaveChanges();
                    }

                    for (i = 0; i < 4; i++)
                    {
                        route.Number        = i + 1;
                        route.PointsFlash   = 1;
                        route.PointsTop     = 1;
                        route.PointsBonus   = 1;
                        route.Type          = "JAUNUČIAI";
                        route.CompetitionId = compId;
                        CompetitionDB.TblRoutesClim.Add(route);
                        CompetitionDB.SaveChanges();
                    }
                    for (i = 0; i < 4; i++)
                    {
                        route.Number        = i + 1;
                        route.PointsFlash   = 1;
                        route.PointsTop     = 1;
                        route.PointsBonus   = 1;
                        route.Type          = "JAUNUOLIAI";
                        route.CompetitionId = compId;
                        CompetitionDB.TblRoutesClim.Add(route);
                        CompetitionDB.SaveChanges();
                    }

                    for (i = 0; i < 4; i++)
                    {
                        route.Number        = i + 1;
                        route.PointsFlash   = 1;
                        route.PointsTop     = 1;
                        route.PointsBonus   = 1;
                        route.Type          = "VAIKAI";
                        route.CompetitionId = compId;
                        CompetitionDB.TblRoutesClim.Add(route);
                        CompetitionDB.SaveChanges();
                    }
                }
            }

            return(ToJsonCreated(CompetitionDB.SaveChanges()));
        }
Example #25
0
        public HttpResponseMessage Post(int compId, int id)
        {
            TblCompetitorsKKT value = new TblCompetitorsKKT();

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

            if (CompetitionDB.TblUsers.First(x => x.TeamId == 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(5, 4));
            }
            else
            {
                dateNow = Convert.ToInt32(DateTime.Now.ToString().Substring(4, 4));
            }
            if ((dateNow - dateYear) > 16)
            {
                value.Group = "JAUNIAI";
            }
            else
            {
                value.Group = "JAUNUČIAI";
            }

            CompetitionDB.TblCompetitorsKKT.Add(value);

            List <RouteKKTModel> routes = CompetitionDB.TblRoutesKKT.ToArray().Where(x => x.CompetitionId == compId && x.Type == value.Group).Select(x => new RouteKKTModel(x)).ToList();
            TblJudgesPaperKKT    paper  = new TblJudgesPaperKKT();

            foreach (RouteKKTModel r in routes)
            {
                paper.JudgeId = 0;
                paper.RouteId = r.Id;
                paper.Time    = "00:00:00";
                paper.Comment = "";
                paper.Date    = DateTime.Now;
                paper.TypeId  = 0;
                paper.UserId  = value.TeamId;
                CompetitionDB.TblJudgesPapersKKT.Add(paper);
                CompetitionDB.SaveChanges();
            }

            return(ToJsonCreated(CompetitionDB.SaveChanges()));
        }
Example #26
0
        public HttpResponseMessage Put(string user, [FromBody] TblUser value)
        {
            CompetitionDB.Entry(value).State = EntityState.Modified;

            return(ToJsonOK(CompetitionDB.SaveChanges()));
        }
Example #27
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()));
        }
Example #28
0
        public HttpResponseMessage Post([FromBody] TblUserRole value)
        {
            CompetitionDB.TblUserRoles.Add(value);

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