public void removeClient(Client client) { try { CarpoolingDAL.Client cl = db.Clients.Single(o => o.idClient == client.Id); db.Clients.DeleteOnSubmit(cl); db.SubmitChanges(); } catch (Exception) { //return false; } CarpoolingDAL.Route r = new CarpoolingDAL.Route(); //return true; }
public bool existsRoute(int routeId) { CarpoolingDAL.Route oldOne = db.Routes.Single(o => o.idRoute == routeId); if (oldOne != null) { return(true); } else { return(false); } }
public void addPlace(Place place, Route route) { try { db.StartFinishes.InsertOnSubmit(RepositoryUtility.createDALStartFinishFromPlace(place, route)); db.SubmitChanges(); } catch (Exception) { //TODO saznaj koje su iznimke //iznimka se generira ako se narusi bilo koje pravilo vezano uz primary key ili foreign key. Znači, iznimka se //generira ako se pokuša dodati osoba koja ima JMBAG koji koristi neka druga osoba, zatim ako se pod osoba.sifUloga //stavi neki broj kojeg nema u tablici Uloga, itd.. //return false; } //return true; }
public void addRoute(Route route) { try { PlaceRepository pr = PlaceRepository.getInstanca(); db.Routes.InsertOnSubmit(RepositoryUtility.createDALRouteFromRoute(route)); pr.addPlace(route.StartingPoint, route); pr.addPlace(route.Destination,route); db.SubmitChanges(); } catch (Exception) { //TODO saznaj koje su iznimke //iznimka se generira ako se narusi bilo koje pravilo vezano uz primary key ili foreign key. Znači, iznimka se //generira ako se pokuša dodati osoba koja ima JMBAG koji koristi neka druga osoba, zatim ako se pod osoba.sifUloga //stavi neki broj kojeg nema u tablici Uloga, itd.. //return false; } //return true; }
public void addFirmRoute(Route route, Client client) { try { CarpoolingDAL.FirmRoute fr = new FirmRoute(); fr.idClient = client.Id; fr.idRoute = route.Id; db.FirmRoutes.InsertOnSubmit(fr); db.SubmitChanges(); } catch (Exception) { //TODO saznaj koje su iznimke //iznimka se generira ako se narusi bilo koje pravilo vezano uz primary key ili foreign key. Znači, iznimka se //generira ako se pokuša dodati osoba koja ima JMBAG koji koristi neka druga osoba, zatim ako se pod osoba.sifUloga //stavi neki broj kojeg nema u tablici Uloga, itd.. //return false; } //return true; }
public void removeRoute(Route route) { try { CarpoolingDAL.Route rt = db.Routes.Single(o => o.idRoute == route.Id); db.Routes.DeleteOnSubmit(rt); var places = db.StartFinishes.Where(s => s.idRoute == route.Id); foreach (CarpoolingDAL.StartFinish res in places) { db.StartFinishes.DeleteOnSubmit(res); } db.SubmitChanges(); } catch (Exception) { //return false; } //return true; }
public void updateRoute(Route route) { try { PlaceRepository pr = PlaceRepository.getInstanca(); ResourceRepository rer = ResourceRepository.getInstanca(); CarpoolingDAL.Route oldOne = db.Routes.Single(o => o.idRoute == route.Id); oldOne.name = route.Name; oldOne.path = route.Path.convertToBinary(); oldOne.routeType = route.Type.Id; pr.updatePlace(route.StartingPoint, route); pr.updatePlace(route.Destination, route); db.SubmitChanges(); } catch (Exception) { //return false; } //return true; }
public Route getRouteById(int idRoute) { PlaceRepository pr = PlaceRepository.getInstanca(); CarpoolingDAL.Route rt = new CarpoolingDAL.Route(); Route rrt = new Route(); try { var query = db.Routes.Where(o => o.idRoute == idRoute).First(); rt = query as CarpoolingDAL.Route; rrt.Id = rt.idRoute; rrt.Name = rt.name; rrt.Path.PathDim = rt.path.ToString(); rrt.Type.Id = rt.routeType; rrt.Type.Name = ((db.RouteTypes.Where(o => o.idRouteType == rt.routeType).First()) as CarpoolingDAL.RouteType).name; rrt.Destination = pr.getPlace(idRoute, Place.DESTINATION); rrt.StartingPoint = pr.getPlace(idRoute, Place.STARTING_POINT); } catch (Exception) { rrt = null; } return(rrt); }
public Route getRouteById(int idRoute) { PlaceRepository pr = PlaceRepository.getInstanca(); CarpoolingDAL.Route rt = new CarpoolingDAL.Route(); Route rrt = new Route(); try { var query = db.Routes.Where(o => o.idRoute == idRoute).First(); rt = query as CarpoolingDAL.Route; rrt.Id = rt.idRoute; rrt.Name = rt.name; rrt.Path.PathDim = rt.path.ToString(); rrt.Type.Id = rt.routeType; rrt.Type.Name = ((db.RouteTypes.Where(o => o.idRouteType == rt.routeType).First()) as CarpoolingDAL.RouteType).name; rrt.Destination = pr.getPlace(idRoute, Place.DESTINATION); rrt.StartingPoint = pr.getPlace(idRoute, Place.STARTING_POINT); } catch (Exception) { rrt = null; } return rrt; }
public void removeFirmRoute(Route route, Client client) { try { CarpoolingDAL.FirmRoute frt = db.FirmRoutes.Single(o => o.idClient == client.Id && o.idRoute == route.Id); db.FirmRoutes.DeleteOnSubmit(frt); db.SubmitChanges(); } catch (Exception) { //return false; } //return true; }
public List<Group> getGroupsByRoute(Route route) { List<Group> listRouGroup = new List<Group>(); var groups = db.Groups.Where(s => s.route == route.Id); foreach (CarpoolingDAL.Group res in groups) { listRouGroup.Add(RepositoryUtility.createGroupFromDALGroup(res as CarpoolingDAL.Group)); } return listRouGroup; }
partial void InsertRoute(Route instance);
private void detach_Routes(Route entity) { this.SendPropertyChanging(); entity.RouteType1 = null; }
private void attach_Routes(Route entity) { this.SendPropertyChanging(); entity.RouteType1 = this; }
public void updatePlace(Place place, Route route) { try { RouteRepository rr = RouteRepository.getInstanca(); ResourceRepository rer = ResourceRepository.getInstanca(); CarpoolingDAL.StartFinish oldOne = db.StartFinishes.Single(o => o.idRoute == route.Id && o.direction == place.InOrOut); oldOne.address = place.Address; oldOne.idCity = place.City.Id; db.SubmitChanges(); } catch (Exception) { //return false; } //return true; }
partial void UpdateRoute(Route instance);
partial void DeleteRoute(Route instance);