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

            if (id != armAndShoulderModel.ID)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
コード例 #2
0
        public IHttpActionResult GetArmAndShoulderModel(int id)
        {
            ArmAndShoulderModel armAndShoulderModel = db.ArmAndShoulders.Find(id);
            string owner = ClaimsPrincipal.Current.FindFirst(ClaimTypes.NameIdentifier).Value;

            if (armAndShoulderModel == null || armAndShoulderModel.Owner != owner)
            {
                return(NotFound());
            }

            return(Ok(armAndShoulderModel));
        }
コード例 #3
0
        public IHttpActionResult PostArmAndShoulderModel(ArmAndShoulderModel armAndShoulderModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            string owner = ClaimsPrincipal.Current.FindFirst(ClaimTypes.NameIdentifier).Value;

            //armAndShoulderModel.Logged = DateTime.UtcNow;
            armAndShoulderModel.Owner = owner;
            db.ArmAndShoulders.Add(armAndShoulderModel);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = armAndShoulderModel.ID }, armAndShoulderModel));
        }