public List <ModelTypePromotions> SelectAll() { using (var db = new DAL.BikeEntities()) { return(db.TypePromotions.Select(MapToApp).ToList()); } }
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); } }
public ModelTypePromotions SelectTypePromotionById(int id) { using (var db = new DAL.BikeEntities()) { return(MapToApp(db.TypePromotions.Find(id))); } }
public void AddTypePromotion(ModelTypePromotions model) { using (var db = new DAL.BikeEntities()) { db.TypePromotions.Add(MapToDB(model)); db.SaveChanges(); } }
public void AddBodyRent(ModelBodyRents model) { using (var db = new DAL.BikeEntities()) { db.BodyRents.Add(MapToDB(model)); db.SaveChanges(); } }
public void DeleteTypePromotion(int id) { using (var db = new DAL.BikeEntities()) { var aDelete = db.TypePromotions.Find(id); db.TypePromotions.Remove(aDelete); db.SaveChanges(); } }
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()); } }
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(); } }
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(); } }
public ModelRents SelectRentById(int id) { try { using (var db = new DAL.BikeEntities()) { return(MapToApp(db.Rents.Find(id))); } } catch (Exception ex) { return(null); } }
public List <ModelClients> SelectAll() { try { using (var db = new DAL.BikeEntities()) { return(db.Clients.Select(MapToApp).ToList()); } } catch (Exception ex) { return(null); } }
public void AddClient(ModelClients model) { try { using (var db = new DAL.BikeEntities()) { db.Clients.Add(MapToDB(model)); db.SaveChanges(); } } catch (Exception ex) { } }
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) { } }
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); } }
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()); } }
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) { } }