예제 #1
0
        public IHttpActionResult PuttblAssetType(int id, tblAssetType tblAssetType)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != tblAssetType.assetTypeId)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
예제 #2
0
        public IHttpActionResult GettblAssetType(int id)
        {
            tblAssetType tblAssetType = db.tblAssetTypes.Find(id);

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

            return(Ok(tblAssetType));
        }
예제 #3
0
        public IHttpActionResult PosttblAssetType(tblAssetType tblAssetType)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.tblAssetTypes.Add(tblAssetType);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = tblAssetType.assetTypeId }, tblAssetType));
        }
예제 #4
0
        public object AddAssetType(string AssetTypeName)
        {
            var          DC           = new DataClassesDataContext();
            tblAssetType AssetTypeObj = new tblAssetType();

            AssetTypeObj.AssetTypeName = AssetTypeName;

            DC.tblAssetTypes.InsertOnSubmit(AssetTypeObj);
            DC.SubmitChanges();

            return(true);
        }
예제 #5
0
        public IHttpActionResult DeletetblAssetType(int id)
        {
            tblAssetType tblAssetType = db.tblAssetTypes.Find(id);

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

            db.tblAssetTypes.Remove(tblAssetType);
            db.SaveChanges();

            return(Ok(tblAssetType));
        }