Beispiel #1
0
        public async Task <IHttpActionResult> PutUserHasSubscription(int id, UserHasSubscription userHasSubscription)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != userHasSubscription.Id)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
Beispiel #2
0
        public async Task <IHttpActionResult> GetUserHasSubscription(int id)
        {
            UserHasSubscription userHasSubscription = await db.UserHasSubscriptions.FindAsync(id);

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

            return(Ok(userHasSubscription));
        }
Beispiel #3
0
        public async Task <IHttpActionResult> PostUserHasSubscription(UserHasSubscription userHasSubscription)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.UserHasSubscriptions.Add(userHasSubscription);
            await db.SaveChangesAsync();

            return(CreatedAtRoute("DefaultApi", new { id = userHasSubscription.Id }, userHasSubscription));
        }
Beispiel #4
0
        public async Task <IHttpActionResult> DeleteUserHasSubscription(int id)
        {
            UserHasSubscription userHasSubscription = await db.UserHasSubscriptions.FindAsync(id);

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

            db.UserHasSubscriptions.Remove(userHasSubscription);
            await db.SaveChangesAsync();

            return(Ok(userHasSubscription));
        }