コード例 #1
0
ファイル: AppHost.cs プロジェクト: yurigorokhov/NServiceKit
 /// <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
ファイル: AppHost.cs プロジェクト: Qasemt/NServiceKit
        /// <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
ファイル: AppHost.cs プロジェクト: yurigorokhov/NServiceKit
        /// <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
ファイル: AppHost.cs プロジェクト: Qasemt/NServiceKit
 /// <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() );
     }
 }