public static DetialsOfVehicles ConvertVehicleToCommon(Details_of_vehicles detialsOfVehicles) { DataBaseEntities1 db = new DataBaseEntities1(); string type = db.Type_of_vehicles.Where(v => v.Id == detialsOfVehicles.Type).Select(c => c.Type).FirstOrDefault(); return(new DetialsOfVehicles(detialsOfVehicles.License_plate, detialsOfVehicles.several_places, detialsOfVehicles.Quantity_of_fuel_per_km, type)); }
public void AddCustomer(DetailsOfCustomer detailsOfCustomer) { DataBaseEntities1 db = new DataBaseEntities1(); db.Customers.Add(detailsOfCustomer.ConvertCustomerToDal()); db.SaveChanges(); }
public void AddTrack(DetailsOfTrack detailsOfTrack) { DataBaseEntities1 db = new DataBaseEntities1(); db.Track_to_travel.Add(detailsOfTrack.ConvertTrackToDal()); db.SaveChanges(); }
public void AddTravel(DetailsOfTravel detailsOfTravel) { DataBaseEntities1 db = new DataBaseEntities1(); db.Travels.Add(detailsOfTravel.ConvertTravelToDal()); db.SaveChanges(); }
public void AddVehicle(DetialsOfVehicles detialsOfVehicles) { DataBaseEntities1 db = new DataBaseEntities1(); db.Details_of_vehicles.Add(detialsOfVehicles.ConvertVehiclesIoDal()); db.SaveChanges(); }
public void AddPassenger(DetailsOfPassenger detailsOfPassenger) { DataBaseEntities1 db = new DataBaseEntities1(); db.Passengers.Add(detailsOfPassenger.ConvertPassengerToDal()); db.SaveChanges(); }
public void AddUser(DetailsOfUser detailsOfUser) { DataBaseEntities1 db = new DataBaseEntities1(); db.Users.Add(detailsOfUser.ConvertUserToDal()); db.SaveChanges(); }
public void UpdateCustomer(DetailsOfCustomer detailsOfCustomer) { Customers customers = Mapper.ConvertCustomerToDal(detailsOfCustomer); using (var db = new DataBaseEntities1()) { db.Entry <Customers>(db.Set <Customers>().Find(customers.Group_s_code)).CurrentValues.SetValues(customers); db.SaveChanges(); } }
public List <DetailsOfCustomer> GetCustomers() { List <Customers> customers; using (var DbContext = new DataBaseEntities1()) { customers = DbContext.Customers.ToList(); } return(customers.Select(c => Mapper.ConvertCustomerToCommon(c)).ToList()); }
public void UpdateTravel(DetailsOfTravel detailsOfTravel) { Travels travels = Mapper.ConvertTravelToDal(detailsOfTravel); using (var db = new DataBaseEntities1()) { db.Entry <Travels>(db.Set <Travels>().Find(travels.Travel_s_code)).CurrentValues.SetValues(travels); db.SaveChanges(); } }
public List <DetailsOfTravel> GetTravels() { List <Travels> travels; using (var DbContext = new DataBaseEntities1()) { travels = DbContext.Travels.ToList(); } return(travels.Select(t => Mapper.ConvertTravelToCommon(t)).ToList()); }
public void UpdatePassenger(DetailsOfPassenger detailsOfPassenger) { Passengers passengers = Mapper.ConvertPassengerToDal(detailsOfPassenger); using (var db = new DataBaseEntities1()) { db.Entry <Passengers>(db.Set <Passengers>().Find(passengers.Passenger_s_code)).CurrentValues.SetValues(passengers); db.SaveChanges(); } }
public List <DetailsOfPassenger> GetPassengers() { List <Passengers> passengers; using (var DbContext = new DataBaseEntities1()) { passengers = DbContext.Passengers.ToList(); } return(passengers.Select(p => Mapper.ConvertPassengerToCommon(p)).ToList()); }
public void UpdateUser(DetailsOfUser detailsOfUser) { Users users = Mapper.ConvertUserToDal(detailsOfUser); using (var db = new DataBaseEntities1()) { db.Entry <Users>(db.Set <Users>().Find(users.User_s_Id)).CurrentValues.SetValues(users); db.SaveChanges(); } }
public List <DetailsOfTrack> GetTracks(int travelCode) { List <Track_to_travel> tracks; using (var DbContext = new DataBaseEntities1()) { tracks = DbContext.Track_to_travel.Where(t => t.Travel_s_code == travelCode).ToList(); } return(tracks.Select(t => Mapper.ConvertTrackToCommon(t)).ToList()); }
public List <DetailsOfUser> GetUsers() { List <Users> users; using (var DbContext = new DataBaseEntities1()) { users = DbContext.Users.Where(u => u.Permition == dal.Permition.Driver).ToList(); } return(users.Select(u => Mapper.ConvertUserToCommon(u)).ToList()); }
public void UpdateVehicle(DetialsOfVehicles detialsOfVehicles) { Details_of_vehicles details_Of_Vehicles = Mapper.ConvertVehiclesIoDal(detialsOfVehicles); using (var db = new DataBaseEntities1()) { db.Entry <Details_of_vehicles>(db.Set <Details_of_vehicles>().Find(details_Of_Vehicles.License_plate)).CurrentValues.SetValues(details_Of_Vehicles); db.SaveChanges(); } }
public List <DetialsOfVehicles> GetVehicles() { List <Details_of_vehicles> details_Of_Vehicles; using (var DbContext = new DataBaseEntities1()) { details_Of_Vehicles = DbContext.Details_of_vehicles.ToList(); } return(details_Of_Vehicles.Select(v => Mapper.ConvertVehicleToCommon(v)).ToList()); }
public void UpdateTrack(DetailsOfTrack detailsOfTrack) { Track_to_travel tracks = Mapper.ConvertTrackToDal(detailsOfTrack); using (var db = new DataBaseEntities1()) { db.Entry <Track_to_travel>(db.Set <Track_to_travel>().Find(tracks.Track_s_code)).CurrentValues.SetValues(tracks); db.SaveChanges(); } }
public void RemovePassenger(string id) { using (var db = new DataBaseEntities1()) { Passengers p = db.Passengers.Find(id); if (p != null) { db.Passengers.Remove(p); db.SaveChanges(); } } }
public void RemoveUser(int id) { using (var db = new DataBaseEntities1()) { Users users = db.Users.Find(id); if (users != null) { db.Users.Remove(users); db.SaveChanges(); } } }
public void RemoveTrack(string id) { using (var db = new DataBaseEntities1()) { Track_to_travel t = db.Track_to_travel.Find(id); if (t != null) { db.Track_to_travel.Remove(t); db.SaveChanges(); } } }
public static Details_of_vehicles ConvertVehiclesIoDal(this common.DetialsOfVehicles detialsOfVehicles) { DataBaseEntities1 db = new DataBaseEntities1(); Details_of_vehicles details_Of_Vehicles_dal = new Details_of_vehicles(); details_Of_Vehicles_dal.License_plate = detialsOfVehicles.License_plate; int type = db.Type_of_vehicles.Where(v => v.Type.Equals(detialsOfVehicles.Type)).Select(c => c.Id).FirstOrDefault(); details_Of_Vehicles_dal.Type = type; details_Of_Vehicles_dal.several_places = detialsOfVehicles.Several_places; details_Of_Vehicles_dal.Quantity_of_fuel_per_km = detialsOfVehicles.Quantity_of_fuel_per_km; return(details_Of_Vehicles_dal); }
public void RemoveCustomer(string id) { using (var db = new DataBaseEntities1()) { // db.Entry(db.Customers.Find(id)).State = System.Data.Entity.EntityState.Deleted; Customers c = db.Customers.Find(id); if (c != null) { db.Customers.Remove(c); db.SaveChanges(); } //db.SaveChanges(); } }
public void RemoveVehicle(int id) { string i = id.ToString(); using (var db = new DataBaseEntities1()) { Details_of_vehicles c = db.Details_of_vehicles.Find(i); if (c != null) { db.Details_of_vehicles.Remove(c); db.SaveChanges(); } } }