예제 #1
0
        public void updateJudoka(JudokaDao judoka)
        {
            using (var db = getConnection())
            {
                const string sql = @"UPDATE Judokas SET lastName = @lastName, firstName = @firstName,
                                        gender = @gender, danKyu = @danKyu, BirthYears = @BirthYears, userId = @userId WHERE id = @id";

                db.Execute(sql, new { judoka.LastName, judoka.FirstName, judoka.Gender, judoka.DanKyu, judoka.BirthYears, judoka.UserId, judoka.Id },
                           commandType: CommandType.Text);
            }
        }
예제 #2
0
        public void insertJudoka(JudokaDao judoka)
        {
            using (var db = getConnection())
            {
                const string sql = @"INSERT INTO Judokas (lastName, firstName, gender, danKyu, BirthYears, userId)
                                        VALUES (@lastName, @firstName, @gender, @danKyu, @BirthYears, @userId)";

                db.Execute(sql, new { judoka.LastName, judoka.FirstName, judoka.Gender, judoka.DanKyu, judoka.BirthYears, judoka.UserId },
                           commandType: CommandType.Text);
            }
        }
예제 #3
0
        public Response getJudoka(int id)
        {
            Response res = new Response();

            try
            {
                JudokaDao newJudoka = judokaSql.getJudokaById(id);
                res.success(newJudoka);
            }
            catch (Exception e)
            {
                res.error(e.Message);
            }
            return(res);
        }
예제 #4
0
        public Response updateJudoka(int id, [FromBody] JudokaDao judoka)
        {
            Response res = new Response();

            try
            {
                judoka.Id = id;
                judokaSql.updateJudoka(judoka);
                res.success(judoka);
            }
            catch (Exception e)
            {
                res.error(e.Message);
            }
            return(res);
        }
예제 #5
0
        public Response createJudoka([FromBody] JudokaDao newJudoka)
        {
            Response res = new Response();

            try
            {
                if (newJudoka.UserId != 0)
                {
                    throw new Exception("U can't do it");
                }
                string userId = User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.Name).Value;

                newJudoka.UserId = Convert.ToInt32(userId);

                judokaSql.insertJudoka(newJudoka);
                res.success(newJudoka);
            }
            catch (Exception e)
            {
                res.error(e.Message);
            }
            return(res);
        }