Пример #1
0
        public IHttpActionResult PutTrunkLiftModel(int id, TrunkLiftModel trunkLiftModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
Пример #2
0
        public IHttpActionResult GetTrunkLiftModel(int id)
        {
            TrunkLiftModel trunkLiftModel = db.TrunkLifts.Find(id);
            string         owner          = ClaimsPrincipal.Current.FindFirst(ClaimTypes.NameIdentifier).Value;

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

            return(Ok(trunkLiftModel));
        }
Пример #3
0
        public IHttpActionResult PostTrunkLiftModel(TrunkLiftModel trunkLiftModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            string owner = ClaimsPrincipal.Current.FindFirst(ClaimTypes.NameIdentifier).Value;

            trunkLiftModel.Owner = owner;
            //trunkLiftModel.Logged = DateTime.UtcNow;
            db.TrunkLifts.Add(trunkLiftModel);
            db.SaveChanges();

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