public static void InsertRenter(Renter renter) { IDbCommand command = null; try { command = DbActions.GetCommand(); string data = string.Format("'{0}', '{1}', '{2}'", renter.Id, renter.First, renter.Last); command.CommandText = string.Format(DbActions.InsertStatement, Renter.TableName, Renter.Columns, data); command.CommandType = CommandType.Text; command.ExecuteNonQuery(); } finally { DbActions.DisposeCommand(command); } }
public IHttpActionResult Update(Renter renter) { //todo: check for no id Database.Update<Renter>(renter); return this.Ok(Database.Get<Renter>(renter.Id)); }
public IHttpActionResult Add(Renter renter) { renter.Id = Guid.NewGuid(); Database.Insert(renter); return this.Ok(Database.Get<Renter>(renter.Id)); }
public static void UpdateRenter(Renter renter) { IDbCommand command = null; try { command = DbActions.GetCommand(); string data = string.Format("First='{0}', Last='{1}'", renter.First, renter.Last); command.CommandText = string.Format(DbActions.UpdateStatement, Renter.TableName, data, Renter.IdColumn, "'" + renter.Id + "'"); command.CommandType = CommandType.Text; command.ExecuteNonQuery(); } finally { DbActions.DisposeCommand(command); } }
public HttpResponseMessage RenterDelete(Renter renter) { try { Database.Update(renter); } catch (Exception e) { return this.Request.CreateErrorResponse(HttpStatusCode.NotAcceptable, e); } return this.Request.CreateResponse(HttpStatusCode.OK, new RowModel(renter)); }
public HttpResponseMessage RenterAdd() { Renter renter = new Renter { First = "first", Last = "last", Id = Guid.NewGuid() }; try { Database.Insert(renter); } catch (Exception e) { return this.Request.CreateErrorResponse(HttpStatusCode.NotAcceptable, e); } return this.Request.CreateResponse(HttpStatusCode.OK, new RowModel(renter)); }