public bool register(LogInInfo log, User aUser) { PsDbContex db = new PsDbContex(); LogInInfo el = db.LogInfos.SingleOrDefault(r => r.Username == log.Username); if (el != null) { return(false); } LogInInfo newInfo = new LogInInfo { ID = 10, Username = log.Username, Password = log.Password, Type = 1, IsBlocked = 0 }; db.LogInfos.Add(newInfo); db.SaveChanges(); string _username = log.Username; List <LogInInfo> logs; try { var res = from info in db.LogInfos where info.Username == _username select info; logs = res.ToList(); } catch (Exception ex) { return(false); } if (logs.Count != 1) { return(false); } User newUser = new User { ID = 10, UserId = logs[0].ID, Email = aUser.Email, Mobile = aUser.Mobile, CarModel = aUser.CarModel, LicensNumber = aUser.LicensNumber }; db.Users.Add(newUser); db.SaveChanges(); return(true); }
public bool cancelRequest(int aRequestId) { PsDbContex db = new PsDbContex(); List <Booking> data; try { var el = from r in db.Bookings where r.ID == aRequestId select r; data = el.ToList(); if (data.Count != 1) { return(false); } db.Bookings.Remove(data[0]); db.SaveChanges(); return(true); } catch { return(false); } }
//pending = 0 and active = 1 public bool acceptRequest(int aRequestId) { // Caution: Update May Not Work.. PsDbContex db = new PsDbContex(); List <Booking> data; try { var el = from r in db.Bookings where r.ID == aRequestId select r; data = el.ToList(); } catch { return(false); } if (data.Count != 1) { return(false); } data[0].IsPending = 0; db.SaveChanges(); return(true); }
public int RequestPlace(Booking book) { PsDbContex db = new PsDbContex(); var x = db.Bookings.Add(book); db.SaveChanges(); return(x.ID); }
public int createPlace(ParkingPlace aParkingPlace) { PsDbContex db = new PsDbContex(); var x = db.ParkingPlaces.Add(aParkingPlace); db.SaveChanges(); return(x.ID); }
public int setNewFacilty(Facility aFacility) { PsDbContex db = new PsDbContex(); var x = db.Facilities.Add(aFacility); db.SaveChanges(); return(x.ID); }
public int SubscribePlace(Subscriptions sub) { PsDbContex db = new PsDbContex(); var x = db.Subscriptions.Add(sub); db.SaveChanges(); return(x.ID); }
public bool createOffer(Offer aOffer) { PsDbContex db = new PsDbContex(); db.Offers.Add(aOffer); db.SaveChanges(); return(true); }
public bool createPromo(Promo aPromo) { PsDbContex db = new PsDbContex(); db.Promos.Add(aPromo); db.SaveChanges(); return(true); }
public bool createReview(Review aReview) { aReview.Time = DateTime.Today; PsDbContex db = new PsDbContex(); db.Reviews.Add(aReview); db.SaveChanges(); return(true); }
public int createPlaceReview(PlaceReview rev) { rev.Time = DateTime.Today; PsDbContex db = new PsDbContex(); var x = db.PlaceReviews.Add(rev); db.SaveChanges(); return(x.ID); }
public bool bookPlace(Booking aBooking, int aUserId) { aBooking.UserId = aUserId; aBooking.IsPending = 0; PsDbContex db = new PsDbContex(); db.Bookings.Add(aBooking); db.SaveChanges(); return(true); }
public bool deletePlace(int aPlaceId) { PsDbContex db = new PsDbContex(); ParkingPlace el = db.ParkingPlaces.SingleOrDefault(r => r.ID == aPlaceId); if (el == null) { return(false); } db.ParkingPlaces.Remove(el); db.SaveChanges(); return(true); }
public bool approvePlace(int aPlaceId) { // Caution: Update May Not Work.. PsDbContex db = new PsDbContex(); ParkingPlace el = db.ParkingPlaces.SingleOrDefault(r => r.ID == aPlaceId); if (el == null) { return(false); } el.IsBlocked = 0; db.SaveChanges(); return(true); }
public bool blockUser(int userId) { // Caution: Update May Not Work.. PsDbContex db = new PsDbContex(); LogInInfo el = db.LogInfos.SingleOrDefault(r => r.ID == userId); if (el == null) { return(false); } el.IsBlocked = 0; db.SaveChanges(); return(true); }
public string Chk() { PlaceReview rev = new PlaceReview() { CarUserId = 2, Time = DateTime.Today.Date, ToPlaceId = 7, Rating = 5, Comment = "OK" }; PsDbContex db = new PsDbContex(); var x = db.PlaceReviews.Add(rev); db.SaveChanges(); return(x.ID.ToString()); }
public bool registerAdmin() { LogInInfo newUser = new LogInInfo { ID = 10, Username = "******", Password = "******", Type = 3, IsBlocked = 0 }; PsDbContex db = new PsDbContex(); db.LogInfos.Add(newUser); db.SaveChanges(); return(true); }
public int editPlace(ParkingPlace aParkingPlace, int aPlaceId) { // Caution: Update May Not Work.. PsDbContex db = new PsDbContex(); ParkingPlace el = db.ParkingPlaces.SingleOrDefault(r => r.ID == aParkingPlace.ID); if (el == null) { return(0); } el.SpotName = aParkingPlace.SpotName; el.SpotLocation = aParkingPlace.SpotLocation; el.PricePerHour = aParkingPlace.PricePerHour; el.Capacity = aParkingPlace.Capacity; db.SaveChanges(); return(1); }