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

            if (id != assetType.Id)
            {
                return BadRequest();
            }

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

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

            return StatusCode(HttpStatusCode.NoContent);
        }
Пример #2
0
        public void Update(AssetType entity, bool commit)
        {
            if (entity == null)
                throw new ArgumentNullException("entity");

            _db.SaveChanges();
        }
Пример #3
0
        public IHttpActionResult PostAssetType(AssetType assetType)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            db.AssetTypes.Add(assetType);
            db.SaveChanges();

            return CreatedAtRoute("DefaultApi", new { id = assetType.Id }, assetType);
        }