public void UpdateOwners(int RoomId, int PartnerId) { Owner owner = new Owner(); owner.RoomId = RoomId; owner.PartnerId = PartnerId; roomDb.FMROwners.Add(owner); roomDb.SaveChanges(); }
public virtual void AddingToWishList(WishList wishList) { try { // FindMyRoomDb fmrDb = new FindMyRoomDb(); fmrDb.FMRWishLists.Add(wishList); fmrDb.SaveChanges(); } catch (Exception ex) { throw ex; } }
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; } }
//This method will post the data to database public void PostUser(User user) { try { roomDb.FMRUsers.Add(user); roomDb.SaveChanges(); } catch (InsertingDataException ex) { throw ex; } catch (Exception e) { throw e; } }
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(); } }
public virtual void PartnerDelete(int UserId) { try { var findPartnerId = partnerDb.FMRUsers.Find(UserId); List <User> list = new List <User>(); if (findPartnerId == null) { throw new Exception(); } if (findPartnerId.UserStatus == "Partner") { partnerDb.FMRUsers.Remove(findPartnerId); partnerDb.SaveChanges(); } } catch (Exception ex) { throw ex; } }
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; } }
public void UpdateImage(List <byte[]> convertedBytes, int roomId) { foreach (Image v in findMyRoomDb.FMRImages.ToList()) { if (v.RoomId == roomId) { v.RoomImage = convertedBytes[0]; findMyRoomDb.SaveChanges(); break; } } //for(int i=0;i<convertedBytes.Count;i++) //{ // if(findMyRoomDb.FMRImages==roomId) // { // } // Image image = new Image(); // image.RoomImage = convertedBytes[i]; // findMyRoomDb.FMRImages.Add(image); // findMyRoomDb.SaveChanges(); //} }
public void UpdatePartner(UserModified user, int id) { try { //var toUpdate = (from users in roomDb.FMRUsers where user.UserId == id select users).FirstOrDefault(); //toUpdate = user; // (from p in roomDb.FMRUsers //where p.UserId == id //select p).ToList().ForEach(x => { // x.UserStatus = user.UserStatus; // x.UserPhoneNumber = user.UserPhoneNumber; // }); //roomDb.FMRUsers.Update(user); User updatePartner = (User)roomDb.FMRUsers.Find(id); if (updatePartner == null) { return; } updatePartner.UserName = user.UserName; updatePartner.UserAddress = user.UserAddress; updatePartner.UserPhoneNumber = user.UserPhoneNumber; updatePartner.UserStatus = user.UserStatus; roomDb.SaveChanges(); if (user.UserStatus.Equals("invalid")) { List <int> list = new List <int>(); foreach (Owner own in roomDb.FMROwners) { if (own.PartnerId == user.UserId) { list.Add(own.RoomId); } } foreach (Room room in roomDb.FMRRooms) { if (list.Contains(room.RoomId)) { room.Status = "unavailable"; } } //roomDb.SaveChanges(); } else if (user.UserStatus.Equals("valid")) { List <int> listtomakeavailable = new List <int>(); foreach (Owner own in roomDb.FMROwners) { if (own.PartnerId == user.UserId) { listtomakeavailable.Add(own.RoomId); } } List <int> listofbookedrooms = new List <int>(); foreach (Book book in roomDb.FMRBookings) { if (listtomakeavailable.Contains(book.RoomId)) { listofbookedrooms.Add(book.RoomId); } } foreach (Room room in roomDb.FMRRooms) { if (listtomakeavailable.Contains(room.RoomId) && !listofbookedrooms.Contains(room.RoomId)) { room.Status = "Available"; } } //roomDb.SaveChanges(); } roomDb.SaveChanges(); } catch (Exception ex) { throw new InsertingDataException(ex.Message); } }