public static void InsertCustomer(Customer Obj_Customer_Insert) { try { using (BikeRentalEntities db = new BikeRentalEntities()) { db.Customers.Add(Obj_Customer_Insert); db.SaveChanges(); } } catch (Exception ex) { throw ex; } }
public static void InsertReturnedBike(Returned Obj_Returned_Bike_Insert) { try { using (BikeRentalEntities db = new BikeRentalEntities()) { db.Returneds.Add(Obj_Returned_Bike_Insert); db.SaveChanges(); } } catch (Exception ex) { throw ex; } }
public static void InsertBike(Bike Obj_Bike_Insert) { try { using (BikeRentalEntities db = new BikeRentalEntities()) { db.Bikes.Add(Obj_Bike_Insert); db.SaveChanges(); } } catch (Exception ex) { throw ex; } }
public static List <Rent> GetRentDetails(string selectedValue) { try { List <Rent> Obj_Rent_Detail = null; using (BikeRentalEntities db = new BikeRentalEntities()) { Obj_Rent_Detail = (from u in db.Rents where u.RentID.ToString() == selectedValue select u).ToList(); } return(Obj_Rent_Detail); } catch (Exception ex) { throw ex; } }
public static void DeleteIssue(string Obj_Issue_Delete) { try { using (BikeRentalEntities db = new BikeRentalEntities()) { //Lembda expression Rent c = db.Rents.SingleOrDefault(x => x.RentID.ToString().Trim() == Obj_Issue_Delete.Trim()); if (c != null) { db.Rents.Remove(c); db.SaveChanges(); } } } catch (Exception ex) { throw ex; } }
public static int UpdateBike(Bike Obj_Bike_Update) { try { using (BikeRentalEntities db = new BikeRentalEntities()) { //Lembda expression Bike c = db.Bikes.SingleOrDefault(x => x.BikeID == Obj_Bike_Update.BikeID); c.Model = Obj_Bike_Update.Model; c.Maker = Obj_Bike_Update.Maker; c.RegistrationNumber = Obj_Bike_Update.RegistrationNumber; c.RentPerDay = Obj_Bike_Update.RentPerDay; db.SaveChanges(); return(Obj_Bike_Update.BikeID); } } catch (Exception ex) { throw ex; } }
public static int UpdateCustomer(Customer Obj_Cust_Update) { try { using (BikeRentalEntities db = new BikeRentalEntities()) { //Lembda expression Customer c = db.Customers.SingleOrDefault(x => x.CustomerID == Obj_Cust_Update.CustomerID); c.FirstName = Obj_Cust_Update.FirstName; c.LastName = Obj_Cust_Update.LastName; c.Address = Obj_Cust_Update.Address; c.Phone = Obj_Cust_Update.Phone; c.LicenseNo = Obj_Cust_Update.LicenseNo; db.SaveChanges(); return(Obj_Cust_Update.CustomerID); } } catch (Exception ex) { throw ex; } }