Exemplo n.º 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()));
        }
Exemplo n.º 2
0
        public HttpResponseMessage Put(int id, [FromBody] TblJudgesPaperKKT value)
        {
            value.Date = DateTime.Now;

            CompetitionDB.Entry(value).State = EntityState.Modified;
            return(ToJsonOK(CompetitionDB.SaveChanges()));
        }
Exemplo n.º 3
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()));
        }
Exemplo n.º 4
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()));
        }
Exemplo n.º 5
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()));
        }
Exemplo n.º 6
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."));
        }
Exemplo n.º 7
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.");*/
        }
Exemplo n.º 8
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."));
        }
Exemplo n.º 9
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()));
        }
Exemplo n.º 10
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()));
        }
Exemplo n.º 11
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."));
        }
Exemplo n.º 12
0
        public HttpResponseMessage Put(string user, [FromBody] TblUser value)
        {
            CompetitionDB.Entry(value).State = EntityState.Modified;

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