コード例 #1
0
        public async Task <IHttpActionResult> PutAgeGroup(int id, AgeGroup ageGroup)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != ageGroup.AgeGroupId)
            {
                return(BadRequest());
            }

            db.Entry(ageGroup).State = EntityState.Modified;

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!AgeGroupExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
コード例 #2
0
        public async Task <IHttpActionResult> PutGender(int id, Gender gender)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != gender.GenderId)
            {
                return(BadRequest());
            }

            db.Entry(gender).State = EntityState.Modified;

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!GenderExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
コード例 #3
0
        public async Task <IHttpActionResult> PutRace(string id, Race race)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != race.RaceId)
            {
                return(BadRequest());
            }

            _DBContext.Entry(race).State = EntityState.Modified;

            try
            {
                await _DBContext.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!RaceExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
コード例 #4
0
        public async Task <ActionResult> UpVote(int id, bool up)
        {
            AppFeature appFeature = db.AppFeatures.Find(id);

            if (appFeature == null)
            {
                return(Json(new { status = "Error" }));
            }

            if (up)
            {
                ++appFeature.VoteCount;
            }
            else
            {
                --appFeature.VoteCount;
            }


            db.Entry(appFeature).State = EntityState.Modified;
            await db.SaveChangesAsync();

            return(Json(new { status = "Success" }));
        }