コード例 #1
0
        public IHttpActionResult PutOwnerPropertyDescription(int id, OwnerPropertyDescription ownerPropertyDescription)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != ownerPropertyDescription.OwnerPropertyId)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
コード例 #2
0
        public IHttpActionResult GetOwnerPropertyDescription(int id)
        {
            OwnerPropertyDescription ownerPropertyDescription = db.OwnerPropertyDescriptions.Find(id);

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

            return(Ok(ownerPropertyDescription));
        }
コード例 #3
0
        public IHttpActionResult PostOwnerPropertyDescription(OwnerPropertyDescription ownerPropertyDescription)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            ownerPropertyDescription.RegistrationDate = DateTime.Now;
            db.OwnerPropertyDescriptions.Add(ownerPropertyDescription);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = ownerPropertyDescription.OwnerPropertyId }, ownerPropertyDescription));
        }
コード例 #4
0
        public IHttpActionResult DeleteOwnerPropertyDescription(int id)
        {
            OwnerPropertyDescription ownerPropertyDescription = db.OwnerPropertyDescriptions.Find(id);

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

            db.OwnerPropertyDescriptions.Remove(ownerPropertyDescription);
            db.SaveChanges();

            return(Ok(ownerPropertyDescription));
        }