Пример #1
0
 /// <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()));
     }
 }
Пример #2
0
        /// <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>()
            };
        }
Пример #3
0
        /// <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>()
            });
        }
Пример #4
0
 /// <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() );
     }
 }