Exemplo n.º 1
0
        //This method will update partner data
        public List <UserModified> GetUserDetails()
        {
            IList <User>        lstUsers = roomDb.FMRUsers.ToList();
            List <UserModified> UserData = new List <UserModified>();

            try
            {
                using (var context = new FindMyRoomDb())
                {
                    foreach (var item in lstUsers)
                    {
                        if (item.UserType == "Partner")
                        {
                            UserModified user = new UserModified();
                            user.UserId          = item.UserId;
                            user.UserName        = item.UserName;
                            user.UserEmail       = item.UserEmail;
                            user.UserPhoneNumber = item.UserPhoneNumber;
                            user.UserAddress     = item.UserAddress;
                            user.UserStatus      = item.UserStatus;
                            user.UserAddress     = item.UserAddress;
                            user.UserType        = item.UserType;
                            UserData.Add(user);
                        }
                    }
                }
                return(UserData);
            }
            catch (Exception ex)
            {
                throw new InsertingDataException(ex.Message);
            }
        }
Exemplo n.º 2
0
        public void UploadImages(List <byte[]> convertedBytes, int roomid)
        {
            FindMyRoomDb findMyRoomDb = new FindMyRoomDb();

            for (int i = 0; i < convertedBytes.Count; i++)
            {
                Image image = new Image();
                image.RoomImage = convertedBytes[i];
                image.RoomId    = roomid;
                findMyRoomDb.FMRImages.Add(image);
                findMyRoomDb.SaveChanges();
            }
        }
Exemplo n.º 3
0
        public virtual int AddRoom(HelperAddRoom postedroom)
        {
            try
            {
                GeoLocation geoLocation = new GeoLocation();

                FindMyRoomDb roomDb = new FindMyRoomDb();
                Room         room   = new Room
                {
                    Cost        = postedroom.RoomCost,
                    City        = postedroom.city.Trim().ToUpper(),
                    Address     = postedroom.Address.Trim(),
                    Area        = postedroom.Area.Trim(),
                    Furniture   = postedroom.Furniture,
                    Description = postedroom.Description,
                    NoOfBeds    = postedroom.NumberOfRooms,
                    Pincode     = postedroom.Pincode,
                    Status      = "Available",
                    RoomType    = postedroom.RoomType,
                };

                foreach (var item in roomDb.FMRRooms)
                {
                    if (item.Cost == room.Cost && item.City.Equals(room.City) && item.Address.Equals(room.Address) &&
                        item.Area.Equals(room.Area) && item.Furniture.Equals(room.Furniture) &&
                        item.NoOfBeds == room.NoOfBeds && item.Pincode == room.Pincode && item.RoomType.Equals(room.RoomType))
                    {
                        throw new RoomInsertingDataException("Room Details are already present");
                    }
                }

                roomDb.FMRRooms.Add(room);
                roomDb.SaveChanges();

                geoLocation.RoomId    = (from r in roomDb.FMRRooms select r.RoomId).LastOrDefault();
                geoLocation.Latitude  = postedroom.Latitude;
                geoLocation.Longitude = postedroom.Longitude;

                roomDb.FMRGeolocation.Add(geoLocation);
                roomDb.SaveChanges();

                var query = roomDb.FMRRooms.LastOrDefault();
                return(query.RoomId);
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Exemplo n.º 4
0
 public virtual User GetUserDetails(int UserId)
 {
     try
     {
         using (var context = new FindMyRoomDb())
         {
             User list = (from u in context.FMRUsers where u.UserId == UserId select u).SingleOrDefault();
             return(list);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 5
0
 public virtual List <User> GetDetails()
 {
     try
     {
         using (var context = new FindMyRoomDb())
         {
             var list = from u in context.FMRUsers select u;
             return(list.ToList <User>());
         }
     }
     catch (Exception ex)
     {
         throw new RetrievingDataException(ex.Message);
     }
 }
Exemplo n.º 6
0
        public List <Room> getAllRooms()
        {
            FindMyRoomDb roomDb   = new FindMyRoomDb();
            List <Room>  allRooms = new List <Room>();

            try
            {
                allRooms = (from rooms in roomDb.FMRRooms
                            select rooms).ToList();
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(allRooms);
        }
Exemplo n.º 7
0
        public List <Room> GetRooms(int UserId)
        {
            //Testing
            try
            {
                //Db Context
                FindMyRoomDb roomDb = new FindMyRoomDb();
                //Converting tables to list
                List <Room>  room  = roomDb.FMRRooms.ToList();
                List <Owner> owner = roomDb.FMROwners.ToList();
                List <User>  user  = roomDb.FMRUsers.ToList();
                //var details = (from r in room where (from o in owner where o.PartnerId==UserId select o.RoomId).Contains(r.RoomId) select r).Distinct();
                //var details = (from r in room where (from o in owner where o.PartnerId.Equals(((from u in user where u.UserStatus.Equals("valid") select u.UserId).Equals(UserId))).Equals(o.PartnerId) select o.RoomId).Contains(r.RoomId) select r).Distinct();

                User userdata = new User();
                foreach (User u in user)
                {
                    if (u.UserId == UserId && u.UserStatus.ToLower().Equals("valid"))
                    {
                        userdata = u;
                    }
                }
                List <int> roomIds = new List <int>();
                foreach (Owner o in owner)
                {
                    if (o.PartnerId == userdata.UserId)
                    {
                        roomIds.Add(o.RoomId);
                    }
                }
                List <Room> roomsdata = new List <Room>();
                foreach (Room r in room)
                {
                    if (roomIds.Contains(r.RoomId))
                    {
                        roomsdata.Add(r);
                    }
                }

                searchedRoomDatas = roomsdata;
            }
            catch (Exception exception)
            {
                throw exception;
            }
            return(searchedRoomDatas);
        }
Exemplo n.º 8
0
        public List <Image> getRoomImages(int roomId)
        {
            FindMyRoomDb roomDb = new FindMyRoomDb();
            List <Image> images = new List <Image>();

            try
            {
                var query = (from roomImages in roomDb.FMRImages
                             where roomId == roomImages.RoomId select roomImages).ToList();

                return(query);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        //Brings all the Distinct Cities from Rooms Table
        public virtual List <string> GetCities()
        {
            List <string> cityList;

            try
            {
                using (FindMyRoomDb context = new FindMyRoomDb())
                {
                    cityList = (from room in context.FMRRooms select room.City).Distinct().ToList();
                }
            }
            catch (Exception exception)
            {
                throw exception;
            }
            return(cityList);
        }
Exemplo n.º 10
0
 public virtual List <GetCustomerOfPartners> GetCustomers(int UserId)
 {
     //Testing
     try
     {
         //Db Context
         FindMyRoomDb roomDb = new FindMyRoomDb();
         //Converting tables to list
         List <User>  user  = roomDb.FMRUsers.ToList();
         List <Room>  room  = roomDb.FMRRooms.ToList();
         List <Owner> owner = roomDb.FMROwners.ToList();
         List <Book>  book  = roomDb.FMRBookings.ToList();
         //performing join
         var details = (from owners in roomDb.FMROwners
                        join users in roomDb.FMRUsers on owners.PartnerId equals users.UserId
                        join booking in roomDb.FMRBookings on owners.RoomId equals booking.RoomId
                        join userss in roomDb.FMRUsers on booking.RenterId equals userss.UserId
                        join rooms in roomDb.FMRRooms on owners.RoomId equals rooms.RoomId
                        select new GetCustomerOfPartners()
         {
             PartnerId = users.UserId,
             UserId = userss.UserId,
             RoomId = rooms.RoomId,
             RoomType = rooms.RoomType,
             UserName = userss.UserName,
             UserEmail = userss.UserEmail,
             UserPhoneNumber = userss.UserPhoneNumber,
             UserAddress = userss.UserAddress
         }).Distinct();
         List <GetCustomerOfPartners> temp = new List <GetCustomerOfPartners>();
         temp = details.ToList();
         foreach (var customers in details)
         {
             if (UserId == customers.PartnerId)
             {
                 GetCustomerOfPartnerslist.Add(customers);
             }
         }
     }
     catch (Exception exception)
     {
         throw exception;
     }
     return(GetCustomerOfPartnerslist);
 }
Exemplo n.º 11
0
        public virtual void  RoomDelete(int roomid)
        {
            try
            {
                FindMyRoomDb roomDb     = new FindMyRoomDb();
                var          findRoomId = roomDb.FMRRooms.Find(roomid);
                List <Room>  list       = new List <Room>();
                if (findRoomId == null)
                {
                    throw new Exception();
                }

                roomDb.FMRRooms.Remove(findRoomId);
                roomDb.SaveChanges();
            }

            catch (Exception ex)
            {
                throw ex;
            }
        }
        //Brings all the Display details of the Room after searching.
        public virtual List <SearchedRoomData> GetSearchedRoomDetails(SearchCityType search)
        {
            List <SearchedRoomData> roomDetails = new List <SearchedRoomData>();

            try
            {
                using (FindMyRoomDb context = new FindMyRoomDb())
                {
                    foreach (Room room in context.FMRRooms)
                    {
                        if (string.Equals(room.City, search.city.Trim(), StringComparison.OrdinalIgnoreCase) &&
                            string.Equals(room.RoomType, search.roomType, StringComparison.OrdinalIgnoreCase) &&
                            string.Equals(room.Status, "Available", StringComparison.OrdinalIgnoreCase))
                        {
                            SearchedRoomData data = new SearchedRoomData
                            {
                                Cost        = room.Cost,
                                City        = room.City,
                                RoomType    = room.RoomType,
                                Area        = room.Area,
                                Description = room.Description,
                                Furniture   = room.Furniture,
                                NoOfBeds    = room.NoOfBeds,
                                RoomId      = room.RoomId
                            };
                            roomDetails.Add(data);
                        }
                    }
                }
            }
            catch (Exception exception)
            {
                throw exception;
            }
            return(roomDetails);
        }