public static List <SubProperty> Search(Nullable <int> PropertyID, Nullable <int> num, Nullable <double> Size, Nullable <double> RoomsNum) { using (ArgamanExpressEntities db = new ArgamanExpressEntities()) { List <SubProperty> sp = new List <SubProperty>(); sp = (from sup in db.SubProperties where sup.status == true select sup).ToList(); if (PropertyID != null && PropertyID != 0) { sp = (from s in sp where s.PropertyID == PropertyID select s).ToList(); } if (num != null && num != 0) { sp = (from s in sp where s.num == num select s).ToList(); } if (Size != null && Size != 0) { sp = (from s in sp where s.Size >= Size select s).ToList(); } if (RoomsNum != null && RoomsNum != 0) { sp = (from s in sp where s.RoomsNum >= RoomsNum select s).ToList(); } sp = sp.OrderBy(spr => spr.IsRented).ToList(); return(sp); } }
public static bool UpdateProperty(Property pd) { using (ArgamanExpressEntities db = new ArgamanExpressEntities()) { Property p = db.Properties.Find(pd.PropertyID); p.OwnerID = pd.OwnerID; p.CityID = pd.CityID; p.StreetID = pd.StreetID; p.Number = pd.Number; p.Size = pd.Size; p.Floor = pd.Floor; p.IsDivided = pd.IsDivided; p.ManagmentPayment = pd.ManagmentPayment; p.IsPaid = pd.IsPaid; p.IsExclusivity = pd.IsExclusivity; p.ExclusivityID = pd.ExclusivityID; p.IsWarranty = pd.IsWarranty; p.IsRented = pd.IsRented; p.RoomsNum = pd.RoomsNum; p.ApartmentNum = pd.ApartmentNum; db.SaveChanges(); return(true); } return(false); }
public static List <Property> Search(string cityName, string streetName, string number, Nullable <int> floor, Nullable <bool> isRented) { using (ArgamanExpressEntities db = new ArgamanExpressEntities()) { List <Property> pro; pro = (from p in db.Properties where p.status == true select p).ToList(); if (cityName != null) { pro = (from p in pro where p.City.CityName.Contains(cityName) select p).ToList(); } if (streetName != null) { pro = (from p in pro where p.Street.StreetName.Contains(streetName) select p).ToList(); } if (number != null) { pro = (from p in pro where p.Number == number select p).ToList(); } if (floor != null) { pro = (from p in pro where p.Floor == floor select p).ToList(); } if (isRented != null) { pro = (from p in pro where p.IsRented == isRented select p).ToList(); } pro = pro.OrderBy(p => p.City.CityName).OrderBy(p => p.Street.StreetName).ToList(); return(pro); } return(null); }
public static List <Rental> Search(Nullable <int> propertyID, string owner, string user, Nullable <DateTime> enteryDate, Nullable <DateTime> endDate) { using (ArgamanExpressEntities db = new ArgamanExpressEntities()) { List <Rental> rentals; rentals = (from r in db.Rentals where r.status == true select r).ToList(); if (propertyID != null && propertyID != 0) { rentals = (from r in rentals where r.PropertyID == propertyID select r).ToList(); } if (owner != null) { List <int> owners = (from own in db.PropertiesOwners where (own.OwnerFirstName + " " + own.OwnerLastName).Contains(owner.Trim()) select own.OwnerID).ToList(); rentals = (from r in rentals where owners.Contains(r.Property.OwnerID) select r).ToList(); } if (user != null) { rentals = (from r in rentals where (r.User.FirstName + ' ' + r.User.FirstName).Contains(user.Trim()) select r).ToList(); } if (enteryDate != null && enteryDate != new DateTime()) { rentals = (from r in rentals where r.EnteryDate >= enteryDate select r).ToList(); } if (endDate != null && endDate != new DateTime()) { rentals = (from r in rentals where r.EndDate <= endDate select r).ToList(); } rentals = rentals.OrderBy(r => r.EndDate).ToList(); return(rentals); } return(null); }
public static List <PropertiesOwner> Search(string OwnerFirstName, string OwnerLastName, string Phone, string Email) { using (ArgamanExpressEntities db = new ArgamanExpressEntities()) { List <PropertiesOwner> po; po = (from p in db.PropertiesOwners where p.status == true select p).ToList(); if (OwnerFirstName != null) { po = (from p in po where p.OwnerFirstName != null && p.OwnerFirstName.Contains(OwnerFirstName) select p).ToList(); } if (OwnerLastName != null) { po = (from p in po where p.OwnerLastName != null && p.OwnerLastName.Contains(OwnerLastName) select p).ToList(); } if (Phone != null) { po = (from p in po where p.Phone != null && p.Phone.Contains(Phone) select p).ToList(); } if (Email != null) { po = (from p in po where p.Email != null && p.Email.Contains(Email) select p).ToList(); } po = po.OrderBy(o => o.OwnerFirstName).OrderBy(o => o.OwnerLastName).ToList(); return(po); } return(null); }
public static List <Task> Search(Nullable <int> TaskTypeId, Nullable <int> ClassificationID, Nullable <System.DateTime> DateForHandling, Nullable <bool> IsHandled) { using (ArgamanExpressEntities db = new ArgamanExpressEntities()) { List <Task> tasks = (from t in db.Tasks where t.status == true select t).ToList(); if (TaskTypeId != 0 && TaskTypeId != null) { tasks = (from t in tasks where t.TaskTypeId == TaskTypeId select t).ToList(); } if (ClassificationID != 0 && ClassificationID != null) { tasks = (from t in tasks where t.ClassificationID == ClassificationID select t).ToList(); } if (DateForHandling != null && DateForHandling != new DateTime()) { tasks = (from t in tasks where t.DateForHandling.Date == DateForHandling.Value.Date select t).ToList(); } if (IsHandled != null) { tasks = (from t in tasks where t.IsHandled == IsHandled select t).ToList(); } tasks = tasks.OrderBy(t => t.ClassificationID).OrderBy(t => t.DateForHandling).ToList(); return(tasks); } return(null); }
public static List <User> Search(string FirstName, string LastName, string SMS, string Email, string Phone) { using (ArgamanExpressEntities db = new ArgamanExpressEntities()) { List <User> users = (from u in db.Users where u.RoleID == 3 && u.status == true select u).ToList(); if (FirstName != null) { users = (from u in users where u.FirstName != null && u.FirstName.Contains(FirstName) select u).ToList(); } if (LastName != null) { users = (from u in users where u.LastName != null && u.LastName.Contains(LastName) select u).ToList(); } if (SMS != null) { users = (from u in users where u.SMS != null && u.SMS.Contains(SMS) select u).ToList(); } if (Email != null) { users = (from u in users where u.Email != null && u.Email.Contains(Email) select u).ToList(); } if (Phone != null) { users = (from u in users where u.Phone != null && u.Phone.Contains(Phone) select u).ToList(); } users = users.OrderBy(r => r.FirstName).OrderBy(r => r.LastName).ToList(); return(users); } return(null); }
public static List <Rental> getRentalsbyRenterID(int id)//פרטי השכרה לפי איידי { using (ArgamanExpressEntities db = new ArgamanExpressEntities()) { List <Rental> rentals = (from r in db.Rentals where r.UserID == id select r).ToList(); return(rentals); } return(null); }
public static bool AddUserDocuments(Document doc) { using (ArgamanExpressEntities db = new ArgamanExpressEntities()) { db.Documents.Add(doc); db.SaveChanges(); return(true); } return(false); }
public static bool AddExclusivityPerson(Exclusivity e) { using (ArgamanExpressEntities db = new ArgamanExpressEntities()) { db.Exclusivitys.Add(e); db.SaveChanges(); return(true); } return(false); }
public static bool DeleteUserDocuments(Document doc) { using (ArgamanExpressEntities db = new ArgamanExpressEntities()) { Document d = db.Documents.Find(doc.DocID); db.Documents.Remove(d); db.SaveChanges(); return(true); } return(false); }
public static bool AddCity(City c) { using (ArgamanExpressEntities db = new ArgamanExpressEntities()) { c.CityId = db.Cities.Count() + 1; db.Cities.Add(c); db.SaveChanges(); return(true); } return(false); }
public static bool DeleteProperty(int id) { using (ArgamanExpressEntities db = new ArgamanExpressEntities()) { Property p = db.Properties.Find(id); p.status = false; db.SaveChanges(); return(true); } return(false); }
public static bool AddStreet(Street s) { using (ArgamanExpressEntities db = new ArgamanExpressEntities()) { s.StreetID = db.Streets.Count() + 1; db.Streets.Add(s); db.SaveChanges(); return(true); } return(false); }
public static int AddUser(User u) { using (ArgamanExpressEntities db = new ArgamanExpressEntities()) { u.status = true; db.Users.Add(u); db.SaveChanges(); return(db.Users.Max(i => i.UserID)); } return(0); }
public static int AddSubProperty(SubProperty sp) { using (ArgamanExpressEntities db = new ArgamanExpressEntities()) { sp.status = true; db.SubProperties.Add(sp); db.SaveChanges(); return(db.SubProperties.Max(i => i.SubPropertyID)); } return(0); }
public static int AddRental(Rental r) { using (ArgamanExpressEntities db = new ArgamanExpressEntities()) { r.status = true; db.Rentals.Add(r); db.SaveChanges(); return(db.Rentals.Max(i => i.RentalID)); } return(0); }
public static int AddPropertyOwner(PropertiesOwner po) { using (ArgamanExpressEntities db = new ArgamanExpressEntities()) { po.status = true; db.PropertiesOwners.Add(po); db.SaveChanges(); return(db.PropertiesOwners.Max(i => i.OwnerID)); //return (from p in db.PropertiesOwners where p.OwnerFirstName==po.OwnerFirstName && p.OwnerLastName==po.OwnerLastName && p.Phone==po.Phone && p.Email==po.Email select p.OwnerID).FirstOrDefault(); } return(0); }
public static int AddProperty(Property pe) { using (ArgamanExpressEntities db = new ArgamanExpressEntities()) { db.Properties.Add(pe); db.SaveChanges(); return(db.Properties.Max(i => i.PropertyID)); } return(0); }
public static int AddTask(Task t) { using (ArgamanExpressEntities db = new ArgamanExpressEntities()) { //t.DateForHandling = new DateTime(t.DateForHandling.Year, t.DateForHandling.Month, t.DateForHandling.Day, 0, 0, 0); t.status = true; db.Tasks.Add(t); db.SaveChanges(); return(db.Tasks.Max(i => i.TaskID)); } return(0); }
public static List <Property> getPropertiesbyRenterID(int id)//דירות ששוכר לפי איידי { using (ArgamanExpressEntities db = new ArgamanExpressEntities()) { List <Property> properties = new List <Property>(); foreach (Rental r in getRentalsbyRenterID(id)) { properties.Add((from p in db.Properties where r.PropertyID == p.PropertyID select p).FirstOrDefault()); } return(properties); } return(null); }