예제 #1
0
        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);
            }
        }
예제 #2
0
        public IHttpActionResult Update(Renter renter)
        {
            //todo: check for no id
            Database.Update<Renter>(renter);

            return this.Ok(Database.Get<Renter>(renter.Id));
        }
예제 #3
0
        public IHttpActionResult Add(Renter renter)
        {
            renter.Id = Guid.NewGuid();
            Database.Insert(renter);

            return this.Ok(Database.Get<Renter>(renter.Id));
        }
예제 #4
0
        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);
            }
        }
예제 #5
0
        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));
        }
예제 #6
0
        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));
        }