Exemplo n.º 1
0
        public IHttpActionResult InsertCompetitor(Competitor competitor)
        {
            PenOCDataContext db = new PenOCDataContext();

            try
            {
                tblCompetitor competitorRecord = new tblCompetitor
                {
                    strFirstName = competitor.firstName,
                    strSurname = competitor.surname,
                    intGender = competitor.genderId,
                };

                db.tblCompetitors.InsertOnSubmit(competitorRecord);
                db.SubmitChanges();

                competitor.id = competitorRecord.idCompetitor;

                return Ok(competitor);
            }
            catch(Exception e)
            {
                return BadRequest(e.Message);
            }
        }
Exemplo n.º 2
0
        public IHttpActionResult UpdateCompetitor(Competitor competitor)
        {
            PenOCDataContext db = new PenOCDataContext();

            tblCompetitor competitorRecord = db.tblCompetitors.Single(c => c.idCompetitor == competitor.id);

            competitorRecord.strFirstName = competitor.firstName;
            competitorRecord.strSurname = competitor.surname;
            competitorRecord.intGender = competitor.genderId;
            competitorRecord.intCategory = competitor.categoryId;
            competitorRecord.intEmitNumber = competitor.emitNumber;
            competitorRecord.strEmail = competitor.email;
            competitorRecord.strTelephone1 = competitor.telephone1;
            competitorRecord.strTelephone2 = competitor.telephone2;

            db.SubmitChanges();

            return Ok(competitor);
        }