Esempio n. 1
0
 public List<Appointment> GetAllAppointments()
 {
     using (var ctx = new SystemContext())
     {
         return ctx.Appointments.Include("Buyer").Include("Seller").ToList();
     }
 }
Esempio n. 2
0
 public List<Location> GetAllLocations()
 {
     using (var ctx = new SystemContext())
     {
         return ctx.Locations.ToList();
     }
 }
Esempio n. 3
0
 public void InsertLocation(Location location)
 {
     using (var ctx = new SystemContext())
     {
         ctx.Locations.Add(location);
         ctx.SaveChanges();
     }
 }
Esempio n. 4
0
 public List<Location> GetLocationsByCity(string city)
 {
     using (var ctx = new SystemContext())
     {
         var loc = ctx.Locations.Where(l => l.City.Contains(city));
         return loc.ToList();
     }
 }
Esempio n. 5
0
 public List<Property> GetAllProperties()
 {
     List<Property> properties;
     using (var ctx = new SystemContext())
     {
         properties = ctx.Properties.ToList();
     }
     return properties;
 }
Esempio n. 6
0
 public void DeleteLocation(Location loc)
 {
     using (var ctx = new SystemContext())
     {
         ctx.Locations.Attach(loc);
         ctx.Locations.Remove(loc);
         ctx.SaveChanges();
     }
 }
Esempio n. 7
0
 public User GetUserByPhone(string phone)
 {
     User user;
     using (var ctx = new SystemContext())
     {
         user = ctx.Users.Where(x => x.Phone == phone).SingleOrDefault();
     }
     return user;
 }
Esempio n. 8
0
 public User GetUserById(int id)
 {
     User user;
     using (var ctx = new SystemContext())
     {
         user = ctx.Users.Where(x => x.Id == id).SingleOrDefault();
     }
     return user;
 }
Esempio n. 9
0
 public void DeleteUser(User user)
 {
     using (var ctx = new SystemContext())
     {
         ctx.Users.Attach(user);
         ctx.Users.Remove(user);
         ctx.SaveChanges();
     }
 }
Esempio n. 10
0
 public Seller GetSellerByMobile(string mobile)
 {
     Seller seller;
     using (var ctx = new SystemContext())
     {
         seller = ctx.Sellers.Where(x => x.Mobile == mobile).SingleOrDefault();
     }
     return seller;
 }
Esempio n. 11
0
 public Seller GetSellerById(int id)
 {
     Seller seller;
     using (var ctx = new SystemContext())
     {
         seller = ctx.Sellers.Where(x => x.Id == id).SingleOrDefault();
     }
     return seller;
 }
Esempio n. 12
0
 public List<Seller> GetAllSellers()
 {
     List<Seller> sellers;
     using (var ctx = new SystemContext())
     {
         sellers = ctx.Sellers.Include("Properties").ToList();
     }
     return sellers;
 }
Esempio n. 13
0
 public List<Property> GetAllProperties(Seller seller)
 {
     List<Property> properties;
     using (var ctx = new SystemContext())
     {
         properties = ctx.Properties.Where(x => x.SellerID == seller.Id).ToList();
     }
     return properties;
 }
Esempio n. 14
0
 public void DeleteSeller(Seller seller)
 {
     using (var ctx = new SystemContext())
     {
         ctx.Sellers.Attach(seller);
         ctx.Sellers.Remove(seller);
         ctx.SaveChanges();
     }
 }
Esempio n. 15
0
 public Property GetProperty(string address)
 {
     Property property;
     using (var ctx = new SystemContext())
     {
         property = ctx.Properties.Where(x => x.Address.Equals(address)).SingleOrDefault();
     }
     return property;
 }
Esempio n. 16
0
 public Location GetLocation(string zipCode)
 {
     Location loc;
     using (var ctx = new SystemContext())
     {
         loc = ctx.Locations.Where(x => x.ZipCode == zipCode).SingleOrDefault();
         return loc;
     }
 }
Esempio n. 17
0
 public void DeleteProperty(Property property)
 {
     using (var ctx = new SystemContext())
     {
         ctx.Properties.Attach(property);
         ctx.Properties.Remove(property);
         ctx.SaveChanges();
     }
 }
Esempio n. 18
0
 public List<Buyer> GetAllBuyers()
 {
     List<Buyer> buyers;
     using (var ctx = new SystemContext())
     {
         buyers = ctx.Buyers.ToList();
     }
     return buyers;
 }
Esempio n. 19
0
 public List<Appointment> GetAppointment(DateTime date)
 {
     List<Appointment> appointments;
     using (var ctx = new SystemContext())
     {
         appointments = ctx.Appointments.Where(a => a.Date == date).ToList();
     }
     return appointments;
 }
Esempio n. 20
0
 public void DeleteAppointment(Appointment appointment)
 {
     using (var ctx = new SystemContext())
     {
         ctx.Appointments.Attach(appointment);
         ctx.Appointments.Remove(appointment);
         ctx.SaveChanges();
     }
 }
Esempio n. 21
0
 public void DeleteBuyer(Buyer buyer)
 {
     using (var ctx = new SystemContext())
     {
         ctx.Buyers.Attach(buyer);
         ctx.Buyers.Remove(buyer);
         ctx.SaveChanges();
     }
 }
Esempio n. 22
0
 public List<Property> GetAllPropertiesByMobile(string mobile)
 {
     List<Property> properties;
     using (var ctx = new SystemContext())
     {
         Buyer b = ctx.Buyers.Where(x => x.Mobile == mobile).SingleOrDefault();
         properties = b.Properties.ToList();
     }
     return properties;
 }
Esempio n. 23
0
 public List<Location> GetAllLocationsByPhone(string phone)
 {
     List<Location> locations;
     using (var ctx = new SystemContext())
     {
         Buyer b = ctx.Buyers.Where(x => x.Phone == phone).SingleOrDefault();
         locations = b.Locations.ToList();
     }
     return locations;
 }
Esempio n. 24
0
 public List<User> GetAllUsers()
 {
     List<User> users;
     using (var ctx = new SystemContext())
     {
         users = ctx.Users.Include(x => x.Appointments)
                          .Include(x => x.Appointments.Select(y => y.Buyer))
                          .Include(x => x.Appointments.Select(y => y.Seller)).ToList();
     }
     return users;
 }
Esempio n. 25
0
 public List<Property> GetPropertiesByAddress(string adress)
 {
     List<Property> properties = new List<Property>();
     using (var ctx = new SystemContext())
     {
         List<Property> allProps = ctx.Properties.ToList();
         foreach (Property p in allProps)
         {
             if(p.Address.Contains(adress))
             {
                 properties.Add(p);
             }
         }
     }
     return properties;
 }
Esempio n. 26
0
 public void InsertAppointment(Appointment appointment, Buyer buyer, Seller seller)
 {
     using (var ctx = new SystemContext())
     {
         ctx.Appointments.Add(appointment);
         if (buyer != null)
         {
             ctx.Buyers.Attach(buyer);
             appointment.Buyer = buyer;
         }
         if (seller != null)
         {
             ctx.Sellers.Attach(seller);
             appointment.Seller = seller;
         }
         ctx.SaveChanges();
     }
 }
Esempio n. 27
0
        public void UpdateAppointment(Appointment appointment, DateTime date, DateTime StartTime, DateTime EndTime,
            string category, string descricption, string status)
        {
            appointment.Date = date;
            appointment.StarTime = StartTime;
            appointment.EndTime = EndTime;
            appointment.Category = category;
            appointment.Description = descricption;
            appointment.Status = status;

            using (var ctx = new SystemContext())
            {
                ctx.Entry(appointment).State = System.Data.Entity.EntityState.Modified;
                ctx.SaveChanges();
            }
        }
Esempio n. 28
0
 public void UpdateBuyer(Buyer buyer)
 {
     //Fire up a new DB context
     using (var ctx = new SystemContext())
     {
         //Match buyer from input with buyer to update from database
         Buyer dbBuyer = ctx.Buyers.Find(buyer.Id);
         //Set the values of the dbBuyer to the values of the buyer from input
         ctx.Entry(dbBuyer).CurrentValues.SetValues(buyer);
         //Save the changes back to the database.
         ctx.SaveChanges();
     }
 }
Esempio n. 29
0
 public void UpdateBuyer(Buyer buyer, List<Property> properties, string name, string address, string zipCode, string phone, string mobile, string email, string misc, string estateType, double minPrice, double maxPrice,
     double lotSizeMin, double lotSizeMax, double probertySizeMin, double probertySizeMax, double desiredRoomsMin, double desiredRoomsMax, List<Location> locations, string otherPref, Boolean contactAllowedByBoligOne,
     Boolean contactAllowedByReal, Boolean allowedEmailSpam, Boolean inRKI, Boolean buyerApproved, string bank, Boolean ownesHouse, Boolean livesForRent)
 {
     buyer.Name = name;
     buyer.Properties = properties;
     buyer.Address = address;
     buyer.ZipCode = zipCode;
     buyer.Phone = phone;
     buyer.Mobile = mobile;
     buyer.Email = email;
     buyer.Misc = misc;
     buyer.EstateType = estateType;
     buyer.MinPrice = minPrice;
     buyer.MaxPrice = maxPrice;
     buyer.LotSizeMin = lotSizeMin;
     buyer.LotSizeMax = lotSizeMax;
     buyer.ProbertySizeMin = probertySizeMin;
     buyer.ProbertySizeMax = probertySizeMax;
     buyer.DesiredRoomsMin = desiredRoomsMin;
     buyer.DesiredRoomsMax = desiredRoomsMax;
     buyer.Locations = locations;
     buyer.OtherPref = otherPref;
     buyer.ContactAllowedByBoligOne = contactAllowedByBoligOne;
     buyer.ContactAllowedByReal = contactAllowedByReal;
     buyer.AllowedEmailSpam = allowedEmailSpam;
     buyer.InRKI = inRKI;
     buyer.BuyerApproved = buyerApproved;
     buyer.Bank = bank;
     buyer.OwnesHouse = ownesHouse;
     buyer.LivesForRent = livesForRent;
     using (var ctx = new SystemContext())
     {
         ctx.Entry(buyer).State = System.Data.Entity.EntityState.Modified;
         ctx.SaveChanges();
     }
 }
Esempio n. 30
0
 public void InsertBuyer(Buyer buyer)
 {
     using (var ctx = new SystemContext())
     {
         ctx.Buyers.Add(buyer);
         ctx.SaveChanges();
     }
 }