Example #1
0
        // POST: odata/PUR010
        public async Task <IHttpActionResult> Post(PUR010 pUR010)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.PUR010.Add(pUR010);

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (PUR010Exists(pUR010.CUST_NO))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(Created(pUR010));
        }
        // POST: odata/PUR010
        public async Task <IHttpActionResult> Post(PUR010 pUR010)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

//            var newPur010 = new PUR010();
//            newPur010.NAME = pUR010.Name;


            db.PUR010.Add(pUR010);

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (PUR010Exists(pUR010.Id))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(Created(pUR010));
        }
Example #3
0
        // DELETE: odata/PUR010(5)
        public async Task <IHttpActionResult> Delete([FromODataUri] string key)
        {
            PUR010 pUR010 = await db.PUR010.FindAsync(key);

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

            db.PUR010.Remove(pUR010);
            await db.SaveChangesAsync();

            return(StatusCode(HttpStatusCode.NoContent));
        }
Example #4
0
        // PUT: odata/PUR010(5)
        public async Task <IHttpActionResult> Put([FromODataUri] string key, Delta <PUR010> patch)
        {
            Validate(patch.GetEntity());

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            PUR010 pUR010 = await db.PUR010.FindAsync(key);

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

            patch.Put(pUR010);

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

            return(Updated(pUR010));
        }