public override Order Get(int id)
 {
     using (TravelRoadContext context = new TravelRoadContext())
     {
         return(context.Order.Include("Line").Include("Line.Bike").Where(x => x.Id == id).FirstOrDefault());
     }
 }
Esempio n. 2
0
 public List <T> ListAll()
 {
     using (TravelRoadContext context = new TravelRoadContext())
     {
         return(context.Set <T>().ToList());
     }
 }
 public int InsertWithIdReturn(Order order)
 {
     using (TravelRoadContext context = new TravelRoadContext())
     {
         context.Order.Add(order);
         context.SaveChanges();
         return(order.Id);
     }
 }
        public List <Bike> Search(string criterio)
        {
            using (TravelRoadContext context = new TravelRoadContext())
            {
                var query = from b in context.Bike
                            where (b.Brand.Contains(criterio)) ||
                            (b.Model.Contains(criterio)) ||
                            (b.Price.ToString().Contains(criterio))
                            select b;

                return(query.ToList());
            }
        }
        public List <Bike> Search(Bike criterio)
        {
            using (TravelRoadContext context = new TravelRoadContext())
            {
                var query = from b in context.Bike
                            where (criterio.Brand == null || b.Brand.Contains(criterio.Brand)) &&
                            (criterio.Model == null || b.Model.Contains(criterio.Model)) &&
                            (criterio.Price == null || criterio.Price == b.Price)
                            select b;

                return(query.ToList());
            }
        }
Esempio n. 6
0
 public virtual T Get(ID id)
 {
     try
     {
         using (TravelRoadContext context = new TravelRoadContext())
         {
             return(context.Set <T>().Find(id));
         }
     }
     catch (Exception ex)
     {
         log.Error(ex, ex.Message, null);
         return(null);
     }
 }
Esempio n. 7
0
 public virtual bool DeleteItem(T item)
 {
     try
     {
         using (TravelRoadContext context = new TravelRoadContext())
         {
             context.Entry <T>(item).State = System.Data.Entity.EntityState.Deleted;
             return(context.SaveChanges() > 0);
         }
     }
     catch (Exception ex)
     {
         log.Error(ex, ex.Message, null);
         return(false);
     }
 }