/// <summary>Post this message.</summary> /// /// <param name="request">The request.</param> /// /// <returns>An object.</returns> public object Post(Rockstars request) { using (var db = DbFactory.OpenDbConnection()) { db.Insert(request.TranslateTo <Rockstar>()); return(Get(new Rockstars())); } }
/// <summary>Gets the given request.</summary> /// /// <param name="request">The request.</param> /// /// <returns>An object.</returns> public object Get(Rockstars request) { if (request.Delete == "reset") { Db.DeleteAll<Rockstar>(); Db.Insert(Rockstar.SeedData); } else if (request.Delete.IsInt()) { Db.DeleteById<Rockstar>(request.Delete.ToInt()); } return new RockstarsResponse { Aged = request.Age, Total = Db.GetScalar<int>("select count(*) from Rockstar"), Results = request.Id != default(int) ? Db.Select<Rockstar>(q => q.Id == request.Id) : request.Age.HasValue ? Db.Select<Rockstar>(q => q.Age == request.Age.Value) : Db.Select<Rockstar>() }; }
/// <summary>Gets the given request.</summary> /// /// <param name="request">The request.</param> /// /// <returns>An object.</returns> public object Get(Rockstars request) { if (request.Delete == "reset") { Db.DeleteAll <Rockstar>(); Db.Insert(Rockstar.SeedData); } else if (request.Delete.IsInt()) { Db.DeleteById <Rockstar>(request.Delete.ToInt()); } return(new RockstarsResponse { Aged = request.Age, Total = Db.GetScalar <int>("select count(*) from Rockstar"), Results = request.Id != default(int) ? Db.Select <Rockstar>(q => q.Id == request.Id) : request.Age.HasValue ? Db.Select <Rockstar>(q => q.Age == request.Age.Value) : Db.Select <Rockstar>() }); }
/// <summary>Post this message.</summary> /// /// <param name="request">The request.</param> /// /// <returns>An object.</returns> public object Post(Rockstars request) { using( var db = DbFactory.OpenDbConnection() ) { db.Insert( request.TranslateTo<Rockstar>() ); return Get( new Rockstars() ); } }