예제 #1
0
        public IHttpActionResult PostLicenseeSub(LicenseeSub licenseeSub)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.LicenseeSubs.Add(licenseeSub);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateException)
            {
                if (LicenseeSubExists(licenseeSub.LicenseeSubType))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = licenseeSub.LicenseeSubType }, licenseeSub));
        }
예제 #2
0
        public IHttpActionResult PutLicenseeSub(string id, LicenseeSub licenseeSub)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != licenseeSub.LicenseeSubType)
            {
                return(BadRequest());
            }

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

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!LicenseeSubExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
예제 #3
0
        public IHttpActionResult GetLicenseeSub(string id)
        {
            LicenseeSub licenseeSub = db.LicenseeSubs.Find(id);

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

            return(Ok(licenseeSub));
        }
예제 #4
0
        public IHttpActionResult DeleteLicenseeSub(string id)
        {
            LicenseeSub licenseeSub = db.LicenseeSubs.Find(id);

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

            db.LicenseeSubs.Remove(licenseeSub);
            db.SaveChanges();

            return(Ok(licenseeSub));
        }