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);
            }
        }
        public List <Booking> getAllBookings(int aOwnerId)
        {
            PsDbContex          db = new PsDbContex();
            List <ParkingPlace> placeData;

            try
            {
                var el = from r in db.ParkingPlaces
                         where r.OwnerId == aOwnerId
                         select r;
                placeData = el.ToList();
            }
            catch
            {
                return(null);
            }

            /**********************************************************************/

            List <Booking> data = new List <Booking>();

            for (int i = 0; i < placeData.Count; i++)
            {
                int placeId = placeData[i].ID;

                Booking el = db.Bookings.SingleOrDefault(r => r.PlaceId == placeId);
                if (el != null)
                {
                    data.Add(el);
                }
            }

            return(data);
        }
        //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);
        }
Exemple #4
0
        public string getFacility(int placeId)
        {
            PsDbContex      db   = new PsDbContex();
            List <Facility> data = new List <Facility>();

            var el = from r in db.Facilities
                     where r.Popularity == placeId
                     select r;

            data = el.ToList();

            if (data.Count == 0)
            {
                return("N/A");
            }
            else
            {
                string str = "\n";
                for (int i = 0; i < data.Count; i++)
                {
                    str += data[i].Description;
                }
                return(str);
            }
        }
Exemple #5
0
        public int login(string aUserName, string password)
        {
            PsDbContex       db = new PsDbContex();
            List <LogInInfo> logs;

            try
            {
                var res = from info in db.LogInfos
                          where info.Username == aUserName && info.Password == password
                          select info;
                logs = res.ToList();
            }
            catch (Exception ex)
            {
                return(0);
            }

            if (logs.Count == 1)
            {
                return(logs[0].ID);
            }
            else
            {
                return(0);
            }
        }
Exemple #6
0
        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);
        }
Exemple #7
0
        // GET: Test
        public string GetRat()
        {
            int        pId = 7;
            PsDbContex db  = new PsDbContex();
            var        rat = db.PlaceReviews.Where(r => r.ToPlaceId == pId).Average(r => r.Rating);

            return(rat.ToString());
        }
Exemple #8
0
        public int setNewFacilty(Facility aFacility)
        {
            PsDbContex db = new PsDbContex();
            var        x  = db.Facilities.Add(aFacility);

            db.SaveChanges();

            return(x.ID);
        }
Exemple #9
0
        public bool createOffer(Offer aOffer)
        {
            PsDbContex db = new PsDbContex();

            db.Offers.Add(aOffer);
            db.SaveChanges();

            return(true);
        }
Exemple #10
0
        public int RequestPlace(Booking book)
        {
            PsDbContex db = new PsDbContex();
            var        x  = db.Bookings.Add(book);

            db.SaveChanges();

            return(x.ID);
        }
Exemple #11
0
        public int createPlace(ParkingPlace aParkingPlace)
        {
            PsDbContex db = new PsDbContex();
            var        x  = db.ParkingPlaces.Add(aParkingPlace);

            db.SaveChanges();

            return(x.ID);
        }
Exemple #12
0
        public int SubscribePlace(Subscriptions sub)
        {
            PsDbContex db = new PsDbContex();
            var        x  = db.Subscriptions.Add(sub);

            db.SaveChanges();

            return(x.ID);
        }
Exemple #13
0
        public bool createPromo(Promo aPromo)
        {
            PsDbContex db = new PsDbContex();


            db.Promos.Add(aPromo);
            db.SaveChanges();

            return(true);
        }
Exemple #14
0
        public bool createReview(Review aReview)
        {
            aReview.Time = DateTime.Today;
            PsDbContex db = new PsDbContex();

            db.Reviews.Add(aReview);
            db.SaveChanges();

            return(true);
        }
        public Booking getBookInfo(int id)
        {
            PsDbContex db = new PsDbContex();
            Booking    el = db.Bookings.SingleOrDefault(r => r.ID == id);

            if (el == null)
            {
                return(el);
            }
            return(el);
        }
Exemple #16
0
        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 Subscriptions getSubInfo(int id)
        {
            PsDbContex    db = new PsDbContex();
            Subscriptions el = db.Subscriptions.SingleOrDefault(r => r.ID == id);

            if (el == null)
            {
                return(el);
            }
            return(el);
        }
Exemple #18
0
        public string getUsername(int id)
        {
            PsDbContex db = new PsDbContex();

            LogInInfo el = db.LogInfos.SingleOrDefault(r => r.ID == id);

            if (el == null)
            {
                return("undefined");
            }
            return(el.Username);
        }
Exemple #19
0
        public int getType(int id)
        {
            PsDbContex db = new PsDbContex();

            LogInInfo el = db.LogInfos.SingleOrDefault(r => r.ID == id);

            if (el == null)
            {
                return(-1);
            }
            return(el.Type);
        }
Exemple #20
0
        public ParkingPlace getPlaceInfo(int id)
        {
            PsDbContex   db = new PsDbContex();
            ParkingPlace el = new ParkingPlace()
            {
                SpotName = "DEBUG"
            };

            el = db.ParkingPlaces.SingleOrDefault(r => r.ID == id);
            //if (el == null) return el;
            return(el);
        }
        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);
        }
Exemple #22
0
        public List <ParkingPlace> getPlaceInfo2(int id)
        {
            PsDbContex          db = new PsDbContex();
            ParkingPlace        el = db.ParkingPlaces.SingleOrDefault(r => r.ID == id);
            List <ParkingPlace> li = new List <ParkingPlace>();

            li.Add(el);
            if (el == null)
            {
                return(li);
            }
            return(li);
        }
Exemple #23
0
        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);
        }
Exemple #24
0
        public List <ParkingPlace> getMatchedPlaces(string match)
        {
            PsDbContex          db = new PsDbContex();
            List <ParkingPlace> data;

            try
            {
                var el = from r in db.ParkingPlaces
                         where r.SpotLocation.Contains(match) || r.SpotName.Contains(match)
                         select r;
                data = el.ToList();
            }
            catch
            {
                return(null);
            }

            return(data);

            /*List<ParkingPlace> data = new List<ParkingPlace>();
             * ParkingPlace p1 = new ParkingPlace()
             * {
             *  ID = 10,
             *  OwnerId = 15,
             *  PricePerHour = 5.0,
             *  SpotName = "SpotA"
             * };
             * ParkingPlace p2 = new ParkingPlace()
             * {
             *  ID = 10,
             *  OwnerId = 15,
             *  PricePerHour = 5.0,
             *  SpotName = "SpotB"
             * };
             * ParkingPlace p3 = new ParkingPlace()
             * {
             *  ID = 10,
             *  OwnerId = 15,
             *  PricePerHour = 5.0,
             *  SpotName = "SpotC"
             * };
             *
             * data.Add(p1);
             * data.Add(p2);
             * data.Add(p3);
             * return data;*/
        }
Exemple #25
0
        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);
        }
Exemple #26
0
        public List <ParkingPlace> getAllPlaces()
        {
            PsDbContex          db = new PsDbContex();
            List <ParkingPlace> data;

            try
            {
                var el = from r in db.ParkingPlaces select r;
                data = el.ToList();
            }
            catch
            {
                return(null);
            }

            return(data);
        }
Exemple #27
0
        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);
        }
Exemple #28
0
        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());
        }
Exemple #29
0
        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);
        }
Exemple #30
0
        public IEnumerable <Owner> getOwners()
        {
            PsDbContex   db = new PsDbContex();
            List <Owner> data;

            try
            {
                var el = from r in db.Owners
                         select r;
                data = el.ToList();
            }
            catch
            {
                return(null);
            }

            return(data);
        }