// GET api/<controller>/5 /// <summary> /// Retrieve the member with a specified member_id /// </summary> /// <param name="member_id">ID generated by database upon its creation</param> public Member Get(int member_id) { MemberPersistence memberp = new MemberPersistence(); memberp.addCallField("member_id", member_id, System.Data.SqlDbType.Int, 4); return((Member)memberp.Get()); }
// GET api/<controller> /// <summary> /// Retrieve a list of members that match your criteria (All fields are optional. If no fields are given all items will be retrieved) /// </summary> /// <param name="is_adult">'true' if the member is an adult 'false' if they are a youth</param> /// <param name="ethnicity">a member's identified ethnicity</param> /// <param name="restricted_to_tech">'true' if the member is only allowed to use technology. 'false' otherwise</param> /// <param name="west_central_resident">'true' if the member is a West Central Resident. 'false' otherwise</param> /// <param name="email">the member's email address</param> public ArrayList Get(bool?is_adult = null, string ethnicity = null, bool?restricted_to_tech = null, bool?west_central_resident = null, string email = null) { MemberPersistence memberp = new MemberPersistence(); memberp.addCallField("is_adult", is_adult, System.Data.SqlDbType.Bit, 1); memberp.addCallField("ethnicity", ethnicity, System.Data.SqlDbType.VarChar, 50); memberp.addCallField("restricted_to_tech", restricted_to_tech, System.Data.SqlDbType.Bit, 1); memberp.addCallField("west_central_resident", west_central_resident, System.Data.SqlDbType.Bit, 1); memberp.addCallField("email", email, System.Data.SqlDbType.VarChar, 50); return(memberp.GetAll()); }
// POST api/<controller> /// <summary> /// Create a new member /// </summary> public HttpResponseMessage Post([FromBody] Member value) { MemberPersistence memberp = new MemberPersistence(); int id = memberp.Save(value, "member_id"); if (id != -1) { value.member_id = id; HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Created); response.Headers.Location = new Uri(Request.RequestUri, String.Format("member?member_id={0}", id)); return(response); } return(Request.CreateResponse(HttpStatusCode.BadRequest)); }
// DELETE api/<controller>/5 /// <summary> /// Delete the member with a specified member_id /// </summary> /// <param name="member_id">ID generated by database upon its creation</param> public HttpResponseMessage Delete(int member_id) { MemberPersistence memberp = new MemberPersistence(); memberp.addCallField("member_id", member_id, System.Data.SqlDbType.Int, 4); bool recordExisted = memberp.Delete(); HttpResponseMessage response; if (recordExisted) { response = Request.CreateResponse(HttpStatusCode.NoContent); } else { response = Request.CreateResponse(HttpStatusCode.NotFound); } return(response); }