public async Task <IActionResult> PostHubShapedCoup([FromBody] HubShapedCoup hubShapedCoup)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.HubShapedCouplings.Add(hubShapedCoup);

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (HubShapedCoupExists(hubShapedCoup.TypeID))
                {
                    return(StatusCode((int)HttpStatusCode.Conflict));
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = hubShapedCoup.TypeID }, hubShapedCoup));
        }
        public async Task <IActionResult> PutHubShapedCoup(string id, [FromBody] HubShapedCoup hubShapedCoup)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != hubShapedCoup.TypeID)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode((int)HttpStatusCode.NoContent));
        }
Пример #3
0
        public async Task<IHttpActionResult> PostHubShapedCoup(HubShapedCoup hubShapedCoup)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            db.HubShapedCouplings.Add(hubShapedCoup);

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (HubShapedCoupExists(hubShapedCoup.TypeID))
                {
                    return Conflict();
                }
                else
                {
                    throw;
                }
            }

            return CreatedAtRoute("DefaultApi", new { id = hubShapedCoup.TypeID }, hubShapedCoup);
        }
Пример #4
0
        public async Task<IHttpActionResult> PutHubShapedCoup(string id, HubShapedCoup hubShapedCoup)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            if (id != hubShapedCoup.TypeID)
            {
                return BadRequest();
            }

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

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

            return StatusCode(HttpStatusCode.NoContent);
        }
        public async Task <IActionResult> GetHubShapedCoup(string id)
        {
            HubShapedCoup hubShapedCoup = await db.HubShapedCouplings.FindAsync(id);

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

            return(Ok(hubShapedCoup));
        }
        public async Task <IActionResult> DeleteHubShapedCoup(string id)
        {
            HubShapedCoup hubShapedCoup = await db.HubShapedCouplings.FindAsync(id);

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

            db.HubShapedCouplings.Remove(hubShapedCoup);
            await db.SaveChangesAsync();

            return(Ok(hubShapedCoup));
        }