public string CreateNewTaxi(Taxi taxi, int idCar) { try { using (TaxiModel db = new TaxiModel()) { if (taxi.Password.Length >= 8 && taxi.Email.Contains("@") && taxi.Email.Contains(".") && taxi.Email.Length > 8) { if (db.Taxies.FirstOrDefault(elem => elem.Email == taxi.Email) != null) { return("This email is in db"); } taxi.Car = db.Cars.First(elem => elem.Id == idCar); taxi.Lat = 0; taxi.Longt = 0; db.Taxies.Add(taxi); db.SaveChanges(); return("Taxi is add"); } else { return("Password must be longer then 8 symvols and you need email"); } } } catch (Exception ex) { Log.Logger(ex.Message); return("Error. Peson is not add"); } }
public string ChangeStateOfOrder(int orderid, string state) { try { using (TaxiModel db = new TaxiModel()) { db.Orders.First(elem => elem.Id == orderid).StateOfOrder = state; db.SaveChanges(); return("State of order is change"); } } catch (Exception ex) { Log.Logger(ex.Message); return("Something wrong. You can't change state of order"); } }
public void Place(double C, double S) { try { using (TaxiModel db = new TaxiModel()) { db.Taxies.First(elem => elem.Email == taxi.Email).Lat = C; db.Taxies.First(elem => elem.Email == taxi.Email).Longt = S; db.SaveChanges(); } Authoriz(taxi.Email, taxi.Password); } catch (Exception ex) { Log.Logger(ex.Message); } }
public bool ChangeImage(byte[] img) { try { using (TaxiModel db = new TaxiModel()) { db.Taxies.First(elem => elem.Id == taxi.Id).Image = img; db.SaveChanges(); Authoriz(taxi.Email, taxi.Password); return(true); } } catch (Exception ex) { Log.Logger(ex.Message); return(false); } }
public bool ChangeCar(int idcar) { try { using (TaxiModel db = new TaxiModel()) { db.Taxies.First(elem => elem.Id == taxi.Id).Car = db.Cars.First(elem => elem.Id == idcar); db.SaveChanges(); Authoriz(taxi.Email, taxi.Password); return(true); } } catch (Exception ex) { Log.Logger(ex.Message); return(false); } }
public string MakeOrder(int idTaxi, double fromLongt, double fromlat, double toLongt, double tolat, string comment = null) { try { using (TaxiModel db = new TaxiModel()) { db.Orders.Add(new Order() { Taxi = db.Taxies.First(elem => elem.Id == idTaxi), Person = db.Persons.First(elem => elem.Id == person.Id), LatFrom = fromlat, LatTo = fromLongt, LongtFrom = tolat, LongtTo = toLongt, Coment = comment, StateOfOrder = "Wait" }); db.SaveChanges(); Authoriz(person.Email, person.Password); return(""); } } catch (Exception ex) { Log.Logger(ex.Message); return("Something wrong. Order is not add"); } }
public string CreateCar(Car car) { try { using (TaxiModel db = new TaxiModel()) { if (car.Marka.Length == 0 || car.MaxNumberOfPassagerOrVantazhKG <= 0) { return("Input true info"); } db.Cars.Add(car); db.SaveChanges(); return(""); } } catch (Exception ex) { Log.Logger(ex.Message); return("Something wrong. Car is not create"); } }
public bool ChangePassword(string password) { try { if (password.Length < 8) { return(false); } using (TaxiModel db = new TaxiModel()) { db.Taxies.First(elem => elem.Id == taxi.Id).Password = password; db.SaveChanges(); Authoriz(taxi.Email, password); return(true); } } catch (Exception ex) { Log.Logger(ex.Message); return(false); } }
public string CreateNewPerson(string Name, string Email, string Password, byte[] img = null) { try { using (TaxiModel db = new TaxiModel()) { if (Password.Length < 8) { return("Small password"); } if (!Email.Contains("@") || !Email.Contains(".") || Email.Length < 8) { return("Wrong email"); } if (Name.Length == 0) { return("Input your name"); } if (db.Persons.FirstOrDefault(elem => elem.Email == Email) != null) { return("This email is in db"); } db.Persons.Add(new Person() { Email = Email, PersonName = Name, Image = img, Password = Password }); db.SaveChanges(); return(""); } } catch (Exception ex) { Log.Logger(ex.Message); return("Error. Peson is not add"); } }