Example #1
0
        // PUT api/Spot_User/5
        public async Task <IHttpActionResult> PutSpot_User(int id, Spot_User spot_user)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != spot_user.Spot_UserId)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
Example #2
0
        public async Task <IHttpActionResult> GetSpot_User(int id)
        {
            Spot_User spot_user = await db.Spot_User.FindAsync(id);

            if (spot_user == null)
            {
                return(NotFound());
            }

            return(Ok(spot_user));
        }
Example #3
0
        public async Task <IHttpActionResult> PostSpot_User(Spot_User spot_user)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.Spot_User.Add(spot_user);
            await db.SaveChangesAsync();

            return(CreatedAtRoute("DefaultApi", new { id = spot_user.Spot_UserId }, spot_user));
        }
Example #4
0
        public async Task <IHttpActionResult> DeleteSpot_User(int id)
        {
            Spot_User spot_user = await db.Spot_User.FindAsync(id);

            if (spot_user == null)
            {
                return(NotFound());
            }

            db.Spot_User.Remove(spot_user);
            await db.SaveChangesAsync();

            return(Ok(spot_user));
        }