public override bool Delete(string entityToDeleteID) { bool result = false; using (TaxiDbContext db = new TaxiDbContext()) { if (db.TaxiDrives.Any(td => td.TaxiDriveID.Equals(entityToDeleteID))) { try { TaxiDrive entityToDelete = db.TaxiDrives.FirstOrDefault(td => td.TaxiDriveID.Equals(entityToDeleteID)); db.TaxiDrives.Remove(entityToDelete); db.SaveChanges(); result = true; } catch (Exception e) { throw e; } } } return(result); }
public override bool Delete(string entityToDeleteID) { bool result = false; using (TaxiDbContext db = new TaxiDbContext()) { if (db.Customers.Any(c => c.Username.Equals(entityToDeleteID))) { try { Customer entityToDelete = db.Customers.FirstOrDefault(c => c.Username.Equals(entityToDeleteID)); db.Customers.Remove(entityToDelete); db.SaveChanges(); result = true; } catch (Exception e) { throw e; } } } return(result); }
public override IEnumerable <TaxiDrive> GetAll() { List <TaxiDrive> result = new List <TaxiDrive>(); using (TaxiDbContext db = new TaxiDbContext()) { try { if (db.TaxiDrives.Count() > 0) { result = new List <TaxiDrive>(db.TaxiDrives.Include(td => td.TaxiDriveDriver) .Include(td => td.TaxiDriveCustomer) .Include(td => td.TaxiDriveDispatcher) .Include(td => td.TaxiDriveComment) .Include(td => td.TaxiDriveStartingLocation) .Include(td => td.TaxiDriveDestination) .ToList()); } } catch (Exception e) { throw e; } } return(result); }
public override TaxiDrive GetSingleEntityByKey(string key) { TaxiDrive result = null; using (TaxiDbContext db = new TaxiDbContext()) { if (db.TaxiDrives.Any(td => td.TaxiDriveID.Equals(key))) { try { result = db.TaxiDrives.Include(td => td.TaxiDriveDriver) .Include(td => td.TaxiDriveCustomer) .Include(td => td.TaxiDriveDispatcher) .Include(td => td.TaxiDriveComment) .Include(td => td.TaxiDriveStartingLocation) .Include(td => td.TaxiDriveDestination) .FirstOrDefault(td => td.TaxiDriveID.Equals(key)); } catch (Exception e) { throw e; } } } return(result); }
public ActionResult AutoIndex() { //return View(TaxiDbContext.ReturnListAll<AutoModel>("Select * from public.\"Auto\"").ToList()); List <AutoModel> autoModel = TaxiDbContext.ReturnListAll <AutoModel>("Select * from public.\"Auto\"").ToList(); return(Json(new { data = autoModel }, JsonRequestBehavior.AllowGet)); }
public override Comment GetSingleEntityByKey(string key) { Comment result = null; using (TaxiDbContext db = new TaxiDbContext()) { if (db.Comments.Any(c => c.CommentID.Equals(key))) { try { result = db.Comments.Include(c => c.CommentOwnerAdmin) .Include(c => c.CommentOwnerDriver) .Include(c => c.CommentOwnerCustomer) .Include(c => c.CommentedTaxiDrive) .FirstOrDefault(a => a.CommentID.Equals(key)); } catch (Exception e) { throw e; } } } return(result); }
public override bool Modify(Vehicle entityToModify) { bool result = false; using (TaxiDbContext db = new TaxiDbContext()) { if (db.Vehicles.Any(v => v.VehicleID.Equals(entityToModify.VehicleID))) { try { Vehicle foundVehicle = db.Vehicles.Include(v => v.VehicleDriver) .SingleOrDefault(v => v.VehicleID.Equals(entityToModify.VehicleID)); db.Vehicles.Attach(foundVehicle); foundVehicle.LicencePlateNo = entityToModify.LicencePlateNo; foundVehicle.ProductionYear = entityToModify.ProductionYear; foundVehicle.VehicleType = entityToModify.VehicleType; foundVehicle.VehicleDriver = entityToModify.VehicleDriver; //NEW db.SaveChanges(); result = true; } catch (Exception e) { throw e; } } } return(result); }
public override bool Modify(Location entityToModify) { bool result = false; using (TaxiDbContext db = new TaxiDbContext()) { if (db.Locations.Any(l => l.LocationID.Equals(entityToModify.LocationID))) { try { Location foundLocation = db.Locations.SingleOrDefault(l => l.LocationID.Equals(entityToModify.LocationID)); db.Locations.Attach(foundLocation); //foundLocation.XCoordinate = entityToModify.XCoordinate; //foundLocation.YCoordinate = entityToModify.YCoordinate; foundLocation.StreetName = entityToModify.StreetName; foundLocation.StreetNumber = entityToModify.StreetNumber; foundLocation.City = entityToModify.City; foundLocation.ZipCode = entityToModify.ZipCode; db.SaveChanges(); result = true; } catch (Exception e) { throw e; } } } return(result); }
public ActionResult DriverIndex() { List <DriverModel> driverModel = TaxiDbContext.ReturnListAll <DriverModel>("SELECT * FROM public.\"Driver\"").ToList(); foreach (DriverModel m in driverModel) { m.AutoModels = TaxiDbContext.ReturnListAll <AutoModel>("Select * from public.\"Auto\" where \"AutoId\" = " + m.AutoId).ToList(); } return(Json(new { data = driverModel }, JsonRequestBehavior.AllowGet)); }
public ActionResult AutoDataEdit(int id = 0) { if (id == 0) { return(View()); } else { return(View(TaxiDbContext.ReturnListAll <AutoModel>("Select * from public.\"Auto\" Where \"AutoId\" = " + id) .FirstOrDefault <AutoModel>())); } }
public void kontaktiranje(object o) { var baza = new TaxiDbContext(); if (!provjeriid(id)) { // obavijestiti da id nije uredu IspisError("Neispravan ID"); } else { bool provjera1 = false; // NE RADI if (false) { // OVO NE RADI!!! // proci kroz vozace i provjeriti ima li vozaca sa ovim id ako nema obavijestiti foreach (var vozac in baza.vozaci) { if (vozac.VozacId == Convert.ToInt32(id)) { provjera1 = true; // nastavak ... } } } // NE RADI foreach (Zaposlenik v in podaci.zaposlenici) { if (v is Vozac) { Vozac v1 = (Vozac)v; if (v1.VozacId == Convert.ToInt32(id)) { provjera1 = true; brojTelefonaVozaca = v1.BrojTelefona; } } } if (!provjera1) { brojTelefonaVozaca = ""; IspisError("Nema vozaca sa ovim ID"); } Promjena("brojTelefonaVozaca"); } }
public override bool Exists(string key) { bool result = false; using (TaxiDbContext db = new TaxiDbContext()) { if (db.Vehicles.Any(a => a.VehicleID.Equals(key))) { result = true; } } return(result); }
public override bool Exists(string key) { bool result = false; using (TaxiDbContext db = new TaxiDbContext()) { if (db.Comments.Any(c => c.CommentID.Equals(key))) { result = true; } } return(result); }
public override bool Exists(string key) { bool result = false; using (TaxiDbContext db = new TaxiDbContext()) { if (db.Customers.Any(c => c.Username.Equals(key))) { result = true; } } return(result); }
public override bool Exists(string key) { bool result = false; using (TaxiDbContext db = new TaxiDbContext()) { if (db.TaxiDrives.Any(td => td.TaxiDriveID.Equals(key))) { result = true; } } return(result); }
public override bool Exists(string key) { bool result = false; using (TaxiDbContext db = new TaxiDbContext()) { if (db.Locations.Any(l => l.LocationID.Equals(key))) { result = true; } } return(result); }
void UpdateGrid() { var Services = new List <Models.Service>(); using (TaxiDbContext taxiDb = new TaxiDbContext()) { Services = taxiDb.Services .Where(s => !s.IsDeleted).ToList(); var VMServices = new List <Models.ViewModels.VMService>(); Services.ForEach( s => VMServices.Add( new Models.ViewModels.VMService() { Id = s.Id, CustomerFullName = s.Customer.FullName, CustomerMobile = s.Customer.Mobile, DriverFullName = s.Driver.FullName, DriverMobile = s.Driver.Mobile, Cost = s.Transaction.Amount, DateTime = s.DateTime, IsPaid = s.Transaction.IsPaid, Path = s.ServicePaths.First().Path.OriginDestination } )); if (Searching) { VMServices = VMServices .Where( s => s.DriverFullName.Contains(txtSearch.Text) || s.DriverMobile.Contains(txtSearch.Text) || s.CustomerFullName.Contains(txtSearch.Text) || s.CustomerMobile.Contains(txtSearch.Text) || s.Path.Contains(txtSearch.Text)) .ToList(); } gridServices.DataSource = VMServices.OrderByDescending(s => s.DateTime); } gridServices.Columns.Where(c => c.Name == "Id").Single().IsVisible = false; gridServices.BestFit(); }
public ActionResult DriverDataEdit(DriverModel driverModel) { if (driverModel.Id == 0) { TaxiDbContext.ExecuteWithoutReturn( "INSERT INTO public.\"Driver\"(\"Name\", \"AutoId\") " + "VALUES('" + driverModel.Name + "','" + driverModel.AutoId + "')"); return(Json(new { success = true, message = "Saved Successfully" }, JsonRequestBehavior.AllowGet)); } else { TaxiDbContext.ExecuteWithoutReturn( "UPDATE public.\"Driver\" SET \"Name\" = '" + driverModel.Name + "', \"AutoId\" = '" + driverModel.AutoId + "' WHERE \"Id\" = " + driverModel.Id + ";"); return(Json(new { success = true, message = "Updated Successfully" }, JsonRequestBehavior.AllowGet)); } }
public override bool Modify(Driver entityToModify) { bool result = false; using (TaxiDbContext db = new TaxiDbContext()) { if (db.Drivers.Any(d => d.Username.Equals(entityToModify.Username))) { try { Driver foundDriver = db.Drivers.Include(d => d.TaxiDrives) .Include(d => d.DriversLocation) .Include(d => d.DriversVehicle) .SingleOrDefault(d => d.Username.Equals(entityToModify.Username)); db.Drivers.Attach(foundDriver); foundDriver.FirstName = entityToModify.FirstName; foundDriver.LastName = entityToModify.LastName; foundDriver.Password = entityToModify.Password; foundDriver.Gender = entityToModify.Gender; foundDriver.JMBG = entityToModify.JMBG; foundDriver.Phone = entityToModify.Phone; foundDriver.Email = entityToModify.Email; //dodaj nove: sa new? entityToModify.TaxiDrives.Where(td => !foundDriver.TaxiDrives.Contains(td)).ToList().ForEach(td => foundDriver.TaxiDrives.Add(td)); //izbaci one kojih vise nema foundDriver.TaxiDrives.Where(td => !entityToModify.TaxiDrives.Contains(td)).ToList().ForEach(td => foundDriver.TaxiDrives.Remove(td)); foundDriver.DriversLocation = entityToModify.DriversLocation; //new? foundDriver.DriversVehicle = entityToModify.DriversVehicle; //new? db.SaveChanges(); result = true; } catch (Exception e) { throw e; } } } return(result); }
public GlavnaSupervizoraVM(PrijavaVM prijavaVM) { podaci = prijavaVM.podaci; this.prijavaVM = prijavaVM; regm = prijavaVM.supervizorIzPrijave; registrujKompanijuS = new RelayCommand <object>(registrujk, provjerareg); registrujDispeceraS = new RelayCommand <object>(registrujd, provjeraregd); registrujSupervizoraS = new RelayCommand <object>(registrujs, provjeraregs); Email = new RelayCommand <object>(sendEmail); trenutniKontak = new Contact(); lista = new List <RegistrovanaMusterija>(); // ovo je samo za testiranje, kad se ubaci tabela u migration promijeniti da parametar u sendEmail bude DbSet var db = new TaxiDbContext(); korisnici = db.musterije; nservice = new NavigationService(); eservice = new EmailCommunicateBehaviour(); }
public ActionResult AutoDataEdit(AutoModel autoModel) { if (autoModel.AutoId == 0) { TaxiDbContext.ExecuteWithoutReturn( "INSERT INTO public.\"Auto\"(\"Brand\", \"Model\") " + "VALUES('" + autoModel.Brand + "','" + autoModel.Model + "')"); return(Json(new { success = true, message = "Saved Successfully" }, JsonRequestBehavior.AllowGet)); } else { TaxiDbContext.ExecuteWithoutReturn( "UPDATE public.\"Auto\" SET \"Brand\" = '" + autoModel.Brand + "', \"Model\" = '" + autoModel.Model + "' WHERE \"AutoId\" = " + autoModel.AutoId + ";"); return(Json(new { success = true, message = "Update Successfully" }, JsonRequestBehavior.AllowGet)); } //return RedirectToAction("AutoIndex"); }
public override bool Modify(TaxiDrive entityToModify) { bool result = false; using (TaxiDbContext db = new TaxiDbContext()) { if (db.TaxiDrives.Any(td => td.TaxiDriveID.Equals(entityToModify.TaxiDriveID))) { try { TaxiDrive foundTaxiDrive = db.TaxiDrives.Include(td => td.TaxiDriveDriver) .Include(td => td.TaxiDriveCustomer) .Include(td => td.TaxiDriveDispatcher) .Include(td => td.TaxiDriveComment) .Include(td => td.TaxiDriveStartingLocation) .Include(td => td.TaxiDriveDestination) .SingleOrDefault(td => td.TaxiDriveID.Equals(entityToModify.TaxiDriveID)); db.TaxiDrives.Attach(foundTaxiDrive); foundTaxiDrive.VehicleType = entityToModify.VehicleType; foundTaxiDrive.DriveStatus = entityToModify.DriveStatus; foundTaxiDrive.Amount = entityToModify.Amount; foundTaxiDrive.TaxiDriveDriver = entityToModify.TaxiDriveDriver; foundTaxiDrive.TaxiDriveCustomer = entityToModify.TaxiDriveCustomer; foundTaxiDrive.TaxiDriveDispatcher = entityToModify.TaxiDriveDispatcher; foundTaxiDrive.TaxiDriveComment = entityToModify.TaxiDriveComment; foundTaxiDrive.TaxiDriveStartingLocation = entityToModify.TaxiDriveStartingLocation; foundTaxiDrive.TaxiDriveDestination = entityToModify.TaxiDriveDestination; db.SaveChanges(); result = true; } catch (Exception e) { throw e; } } } return(result); }
public override IEnumerable <Vehicle> GetAll() { List <Vehicle> result = new List <Vehicle>(); using (TaxiDbContext db = new TaxiDbContext()) { try { if (db.Vehicles.Count() > 0) { result = new List <Vehicle>(db.Vehicles.Include(v => v.VehicleDriver).ToList()); } } catch (Exception e) { throw e; } } return(result); }
public override Admin GetSingleEntityByKey(string key) { Admin result = null; using (TaxiDbContext db = new TaxiDbContext()) { if (db.Admins.Any(a => a.Username.Equals(key))) { try { result = db.Admins.Include(a => a.TaxiDrives).FirstOrDefault(a => a.Username.Equals(key)); } catch (Exception e) { throw e; } } } return(result); }
public override IEnumerable <Admin> GetAll() { List <Admin> result = new List <Admin>(); using (TaxiDbContext db = new TaxiDbContext()) { try { if (db.Admins.Count() > 0) { result = new List <Admin>(db.Admins.Include(a => a.TaxiDrives).ToList()); } } catch (Exception e) { throw e; } } return(result); }
public override Customer GetSingleEntityByKey(string key) { Customer result = null; using (TaxiDbContext db = new TaxiDbContext()) { if (db.Customers.Any(c => c.Username.Equals(key))) { try { result = db.Customers.Include(c => c.TaxiDrives).FirstOrDefault(c => c.Username.Equals(key)); } catch (Exception e) { throw e; } } } return(result); }
public override IEnumerable <Location> GetAll() { List <Location> result = new List <Location>(); using (TaxiDbContext db = new TaxiDbContext()) { try { if (db.Locations.Count() > 0) { result = new List <Location>(db.Locations.ToList()); } } catch (Exception e) { throw e; } } return(result); }
public override Location GetSingleEntityByKey(string key) { Location result = null; using (TaxiDbContext db = new TaxiDbContext()) { if (db.Locations.Any(l => l.LocationID.Equals(key))) { try { result = db.Locations.FirstOrDefault(l => l.LocationID.Equals(key)); } catch (Exception e) { throw e; } } } return(result); }
public override IEnumerable <Customer> GetAll() { List <Customer> result = new List <Customer>(); using (TaxiDbContext db = new TaxiDbContext()) { try { if (db.Customers.Count() > 0) { result = new List <Customer>(db.Customers.Include(c => c.TaxiDrives).ToList()); } } catch (Exception e) { throw e; } } return(result); }
public override bool Modify(Admin entityToModify) { bool result = false; using (TaxiDbContext db = new TaxiDbContext()) { if (db.Admins.Any(a => a.Username.Equals(entityToModify.Username))) { try { Admin foundAdmin = db.Admins.Include(a => a.TaxiDrives).SingleOrDefault(a => a.Username.Equals(entityToModify.Username)); db.Admins.Attach(foundAdmin); foundAdmin.FirstName = entityToModify.FirstName; foundAdmin.LastName = entityToModify.LastName; foundAdmin.Password = entityToModify.Password; foundAdmin.Gender = entityToModify.Gender; foundAdmin.JMBG = entityToModify.JMBG; foundAdmin.Phone = entityToModify.Phone; foundAdmin.Email = entityToModify.Email; //dodaj nove entityToModify.TaxiDrives.Where(td => !foundAdmin.TaxiDrives.Contains(td)).ToList().ForEach(td => foundAdmin.TaxiDrives.Add(td)); //izbaci one kojih vise nema foundAdmin.TaxiDrives.Where(td => !entityToModify.TaxiDrives.Contains(td)).ToList().ForEach(td => foundAdmin.TaxiDrives.Remove(td)); db.SaveChanges(); result = true; } catch (Exception e) { throw e; } } } return(result); }