Exemplo n.º 1
0
        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());
            }

            var response = new RockstarsResponse
            {
                Aged    = request.Age,
                Total   = Db.Scalar <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>()
            };

            if (request.View != null || request.Template != null)
            {
                return new HttpResult(response)
                       {
                           View     = request.View,
                           Template = request.Template,
                       }
            }
            ;

            return(response);
        }
Exemplo n.º 2
0
 public object Post(Rockstars request)
 {
     Db.Insert(request.ConvertTo <Rockstar>());
     return(Get(new Rockstars()));
 }
Exemplo n.º 3
0
 public object Post(Rockstars request)
 {
     Db.Insert(request.TranslateTo<Rockstar>());
     return Get(new Rockstars());
 }
Exemplo n.º 4
0
        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());
            }

            var response = 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>()
            };

            if (request.View != null || request.Template != null)
                return new HttpResult(response) {
                    View = request.View,
                    Template = request.Template,
                };

            return response;
        }
Exemplo n.º 5
0
 public object Post(Rockstars request)
 {
     Db.Insert(request.ConvertTo<Rockstar>());
     return Get(new Rockstars());
 }
Exemplo n.º 6
0
 public object Post(Rockstars request)
 {
     Db.Insert(request.TranslateTo <Rockstar>());
     return(Get(new Rockstars()));
 }