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

            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>()
            });
        }
Exemplo n.º 2
0
 public object Post(Rockstars request)
 {
     Db.Insert(request.TranslateTo <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());
            }

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