Beispiel #1
0
 public List <ModelTypePromotions> SelectAll()
 {
     using (var db = new DAL.BikeEntities())
     {
         return(db.TypePromotions.Select(MapToApp).ToList());
     }
 }
Beispiel #2
0
        public List <ModelDetailRents> SelectAll()
        {
            try
            {
                using (var db = new DAL.BikeEntities())
                {
                    var result = from d in db.Rents
                                 join c in db.Clients
                                 on d.clients_id equals c.id
                                 join p in db.TypePromotions
                                 on d.typepromotions_id equals p.id
                                 into cJoin
                                 from cj in cJoin.DefaultIfEmpty()
                                 select new ModelDetailRents
                    {
                        id                = d.id,
                        price             = d.price,
                        typepromotions_id = d.typepromotions_id,
                        clients_id        = d.clients_id,
                        date              = d.date,
                        quantity          = d.quantity,
                        client            = c.name,
                        promotion         = cj.name
                    };

                    //return db.Rents.Select(MapToApp).ToList();
                    return(result.ToList());;
                }
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
Beispiel #3
0
 public ModelTypePromotions SelectTypePromotionById(int id)
 {
     using (var db = new DAL.BikeEntities())
     {
         return(MapToApp(db.TypePromotions.Find(id)));
     }
 }
Beispiel #4
0
 public void AddTypePromotion(ModelTypePromotions model)
 {
     using (var db = new DAL.BikeEntities())
     {
         db.TypePromotions.Add(MapToDB(model));
         db.SaveChanges();
     }
 }
Beispiel #5
0
 public void AddBodyRent(ModelBodyRents model)
 {
     using (var db = new DAL.BikeEntities())
     {
         db.BodyRents.Add(MapToDB(model));
         db.SaveChanges();
     }
 }
Beispiel #6
0
 public void DeleteTypePromotion(int id)
 {
     using (var db = new DAL.BikeEntities())
     {
         var aDelete = db.TypePromotions.Find(id);
         db.TypePromotions.Remove(aDelete);
         db.SaveChanges();
     }
 }
Beispiel #7
0
 public List <ModelTypePromotions> SelectWhereQuantity(int cant)
 {
     using (var db = new DAL.BikeEntities())
     {
         var result = from promotion in db.TypePromotions
                      where promotion.quantity_min <= cant && promotion.quantity_max >= cant
                      select promotion;
         return(result.Select(MapToApp).ToList());
     }
 }
Beispiel #8
0
 public void EditTypeRent(ModelTypeRents model)
 {
     using (var db = new DAL.BikeEntities())
     {
         var aEdit = db.TypeRents.Find(model.id);
         aEdit.name  = model.name;
         aEdit.price = model.price;
         db.SaveChanges();
     }
 }
Beispiel #9
0
 public void EditTypePromotion(ModelTypePromotions model)
 {
     using (var db = new DAL.BikeEntities())
     {
         var aEdit = db.TypePromotions.Find(model.id);
         aEdit.name         = model.name;
         aEdit.discount     = model.discount;
         aEdit.quantity_min = model.quantity_min;
         aEdit.quantity_max = model.quantity_max;
         db.SaveChanges();
     }
 }
Beispiel #10
0
 public ModelRents SelectRentById(int id)
 {
     try
     {
         using (var db = new DAL.BikeEntities())
         {
             return(MapToApp(db.Rents.Find(id)));
         }
     }
     catch (Exception ex)
     {
         return(null);
     }
 }
Beispiel #11
0
 public List <ModelClients> SelectAll()
 {
     try
     {
         using (var db = new DAL.BikeEntities())
         {
             return(db.Clients.Select(MapToApp).ToList());
         }
     }
     catch (Exception ex)
     {
         return(null);
     }
 }
Beispiel #12
0
 public void AddClient(ModelClients model)
 {
     try
     {
         using (var db = new DAL.BikeEntities())
         {
             db.Clients.Add(MapToDB(model));
             db.SaveChanges();
         }
     }
     catch (Exception ex)
     {
     }
 }
Beispiel #13
0
 public void DeleteRent(int id)
 {
     try
     {
         using (var db = new DAL.BikeEntities())
         {
             var aDelet = db.Rents.Find(id);
             db.Rents.Remove(aDelet);
             db.SaveChanges();
         }
     }
     catch (Exception ex)
     {
     }
 }
Beispiel #14
0
 public int AddRent(ModelRents model)
 {
     try
     {
         using (var db = new DAL.BikeEntities())
         {
             db.Rents.Add(MapToDB(model));
             db.SaveChanges();
             return(MapToApp(db.Set <DAL.Rents>().OrderByDescending(t => t.id).FirstOrDefault()).id);
         }
     }
     catch (Exception ex)
     {
         return(0);
     }
 }
Beispiel #15
0
 public List <ModelBodyDetails> SelectBodyRentById(int id)
 {
     using (var db = new DAL.BikeEntities())
     {
         var result = from b in db.BodyRents
                      join t in db.TypeRents
                      on b.typerents_id equals t.id
                      where b.rents_id == id
                      select new ModelBodyDetails
         {
             price    = b.price,
             date     = b.date,
             typerent = t.name
         };
         return(result.ToList());
     }
 }
Beispiel #16
0
 public void EditClient(ModelClients model)
 {
     try
     {
         using (var db = new DAL.BikeEntities())
         {
             var aEdit = db.Clients.Find(model.id);
             aEdit.name      = model.name;
             aEdit.surname   = model.surname;
             aEdit.email     = model.email;
             aEdit.telephone = model.telephone;
             db.SaveChanges();
         }
     }
     catch (Exception ex)
     {
     }
 }