/// <summary> /// Create a new asset object. /// </summary> /// <param name="id">Initial value of the id property.</param> /// <param name="facility_id">Initial value of the facility_id property.</param> /// <param name="room_id">Initial value of the room_id property.</param> /// <param name="name">Initial value of the name property.</param> /// <param name="add_date">Initial value of the add_date property.</param> /// <param name="last_scan">Initial value of the last_scan property.</param> public static asset Createasset(global::System.Int32 id, global::System.Int32 facility_id, global::System.Int32 room_id, global::System.String name, global::System.DateTime add_date, global::System.DateTime last_scan) { asset asset = new asset(); asset.id = id; asset.facility_id = facility_id; asset.room_id = room_id; asset.name = name; asset.add_date = add_date; asset.last_scan = last_scan; return(asset); }
// POST api/Asset public HttpResponseMessage Postasset(asset asset) { if (ModelState.IsValid) { db.assets.AddObject(asset); db.SaveChanges(); HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Created, asset); response.Headers.Location = new Uri(Url.Link("DefaultApi", new { id = asset.id })); return response; } else { return Request.CreateResponse(HttpStatusCode.BadRequest); } }
// PUT api/Asset/5 public HttpResponseMessage Putasset(int id, asset asset) { if (ModelState.IsValid && id == asset.id) { db.assets.Attach(asset); db.ObjectStateManager.ChangeObjectState(asset, EntityState.Modified); try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { return Request.CreateResponse(HttpStatusCode.NotFound); } return Request.CreateResponse(HttpStatusCode.OK); } else { return Request.CreateResponse(HttpStatusCode.BadRequest); } }
/// <summary> /// Deprecated Method for adding a new object to the assets EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToassets(asset asset) { base.AddObject("assets", asset); }
/// <summary> /// Create a new asset object. /// </summary> /// <param name="id">Initial value of the id property.</param> /// <param name="facility_id">Initial value of the facility_id property.</param> /// <param name="room_id">Initial value of the room_id property.</param> /// <param name="name">Initial value of the name property.</param> /// <param name="add_date">Initial value of the add_date property.</param> /// <param name="last_scan">Initial value of the last_scan property.</param> public static asset Createasset(global::System.Int32 id, global::System.Int32 facility_id, global::System.Int32 room_id, global::System.String name, global::System.DateTime add_date, global::System.DateTime last_scan) { asset asset = new asset(); asset.id = id; asset.facility_id = facility_id; asset.room_id = room_id; asset.name = name; asset.add_date = add_date; asset.last_scan = last_scan; return asset; }