Beispiel #1
0
        public async Task <IHttpActionResult> PostNCSInfo(NCSInfo nCSInfo)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.NCSInfoes.Add(nCSInfo);

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (NCSInfoExists(nCSInfo.InstitutionId))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = nCSInfo.InstitutionId }, nCSInfo));
        }
Beispiel #2
0
        public async Task <IHttpActionResult> PutNCSInfo(string id, NCSInfo nCSInfo)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != nCSInfo.InstitutionId)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
Beispiel #3
0
        public async Task <IHttpActionResult> GetNCSInfo(string id)
        {
            NCSInfo nCSInfo = await db.NCSInfoes.FindAsync(id);

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

            return(Ok(nCSInfo));
        }
Beispiel #4
0
        public async Task <IHttpActionResult> DeleteNCSInfo(string id)
        {
            NCSInfo nCSInfo = await db.NCSInfoes.FindAsync(id);

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

            db.NCSInfoes.Remove(nCSInfo);
            await db.SaveChangesAsync();

            return(Ok(nCSInfo));
        }