Esempio n. 1
0
 //поиск квартиры
 public Apartment SearchApart(string searchStr)
 {
     using (RealtorContext db = new RealtorContext())
     {
         return(db.Apartments.Where(ap => ap.Title.Contains(searchStr) == true).FirstOrDefault());
     }
 }
Esempio n. 2
0
 //Возврат всех работников
 public List <Employee> GetEmployee()
 {
     using (RealtorContext db = new RealtorContext())
     {
         return(db.Employees.ToList());
     }
 }
Esempio n. 3
0
 //поиск картинки по id
 public byte[] SearchApart(int indexApart)
 {
     using (RealtorContext db = new RealtorContext())
     {
         return(db.Pictures.Where(pc => pc.ApartmentId == indexApart).Select(pc1 => pc1.Image).FirstOrDefault());
     }
 }
Esempio n. 4
0
 //выборка всей квартир которых нету в брони
 public List <Apartment> GetApartment()
 {
     using (RealtorContext db = new RealtorContext())
     {
         //var query = from ap in db.Apartments
         //            from bk in db.Bookings
         //            where ap.Id != bk.ApartmentId
         //            select ap;
         return(db.Apartments.ToList());
     }
 }
Esempio n. 5
0
        //изменение данных о картинке
        internal void ChangePicture(int indexApart, byte[] bt)
        {
            using (RealtorContext db = new RealtorContext())
            {
                Picture pc = db.Pictures.Where(p => p.ApartmentId == indexApart).FirstOrDefault();
                pc.ApartmentId = indexApart;
                pc.Image       = bt;

                db.SaveChanges();
            }
        }
Esempio n. 6
0
        public RealtorController(RealtorContext context)
        {
            this.db = context;

            if (db.Realtors.Any())
            {
                /*
                 * db.Realtors.Add(new Realtor { Firstname = "Николай", Lastname = "Котенко", Division = 1, CreatedDateTime = DateTime.Now.Date });
                 * db.Realtors.Add(new Realtor { Firstname = "Елена", Lastname = "Котенко", Division = 2, CreatedDateTime = DateTime.Now.Date });
                 * db.SaveChanges();*/
            }
        }
Esempio n. 7
0
        public RealtorsController(RealtorContext context)
        {
            this.db = context;
            //        if (!db.Realtors.Any())
            //        {
            //            db.Realtors.Add(new Realtor { FirstName = "Roman", LastName = "Mishin", DateTime = DateTime.Now
            //});
            //            db.Realtors.Add(new Realtor { FirstName = "Jon", LastName = "Dow", DateTime = DateTime.Now
            //            });

            //            db.SaveChanges();
            //        }
        }
Esempio n. 8
0
 //измен данных о работнике
 internal void ChangeEmployee(string FName, string LName, string Password, string Email, string Position, int index)
 {
     using (RealtorContext db = new RealtorContext())
     {
         Employee e = db.Employees.Where(em => em.Id == index).FirstOrDefault();
         e.FirstName  = FName;
         e.SecondName = LName;
         e.Email      = Email;
         e.Password   = Password;
         e.Position   = Position;
         db.SaveChanges();
     }
 }
Esempio n. 9
0
        //добавление картинки
        public void AddPicture(int index, byte[] bt)
        {
            Picture pc = new Picture();

            using (RealtorContext db = new RealtorContext())
            {
                pc.ApartmentId = index;
                pc.Image       = bt;

                db.Pictures.Add(pc);
                db.SaveChanges();
            }
        }
Esempio n. 10
0
        //добав нового работника
        public void AddEmployee(string FName, string LName, string Email, string Password, string Position)
        {
            Employee em = new Employee();

            using (RealtorContext db = new RealtorContext())
            {
                em.FirstName  = FName;
                em.SecondName = LName;
                em.Email      = Email;
                em.Password   = Password;
                em.Position   = Position;

                db.Employees.Add(em);
                db.SaveChanges();
            }
        }
Esempio n. 11
0
        public void SaleApart(int indexApart)
        {
            Purchase pr = new Purchase();

            using (RealtorContext db = new RealtorContext())
            {
                db.Clients.Add(new Client {
                    FirstName = "2", SecondName = "1"
                });
                pr.ApartmentId  = indexApart;
                pr.ClientId     = 1;
                pr.DatePurchase = DateTime.Now;
                db.Purchases.Add(pr);
                db.SaveChanges();
            }
        }
        public MainWindow()
        {
            InitializeComponent();

            db             = new UserContext();
            realtorContext = new RealtorContext();
            db.Users.Load();
            realtorContext.Realtors.Load();
            userGrid.ItemsSource    = db.Users.Local.ToBindingList();
            realtorGrid.ItemsSource = realtorContext.Realtors.Local.ToBindingList();

            leviGrid.ItemsSource = ol;


            this.Closing += MainWindow_Closing;
        }
 public string DeleteHouse(HouseListing listing)
 {
     if (listing != null)
     {
         using (RealtorContext dataContext = new RealtorContext())
         {
             int no        = Convert.ToInt32(listing.Id);
             var houseList = dataContext.Houses.Where(x => x.Id == no).FirstOrDefault();
             dataContext.Houses.Remove(houseList);
             dataContext.SaveChanges();
             return("House Deleted");
         }
     }
     else
     {
         return("Invalid House");
     }
 }
Esempio n. 14
0
        //изменение данных о квартире
        internal void ChangeApartment(string title, int area, int countRoom, int floor, int number, int price, string address, int index)
        {
            using (RealtorContext db = new RealtorContext())
            {
                Apartment ap = db.Apartments.Where(a => a.Id == index).FirstOrDefault();
                if (ap != null)
                {
                    ap.Title     = title;
                    ap.Area      = area;
                    ap.CountRoom = countRoom;
                    ap.Floor     = floor;
                    ap.Number    = number;
                    ap.Price     = price;
                    ap.Address   = address;

                    db.SaveChanges();
                }
            }
        }
 public ControlStatistic()
 {
     InitializeComponent();
     using (RealtorContext db = new RealtorContext())
     {
         var query = (from pr in db.Purchases
                      group pr by pr.DatePurchase.Month into s
                      select new { Date = s.Key, Count = s.Count() }).ToList();
         //charStatistic.Series["Salary"].XValueMember = "Date";
         //charStatistic.Series["Salary"].XValueType = System.Windows.Forms.DataVisualization.Charting.ChartValueType.DateTime;
         //charStatistic.Series["Salary"].YValueMembers = "Count";
         //charStatistic.Series["Salary"].YValueType = System.Windows.Forms.DataVisualization.Charting.ChartValueType.Int32;
         charStatistic.DataSource = query;
         foreach (var item in query)
         {
             charStatistic.Series["Salary"].Points.AddXY(query.Count, 1);
         }
     }
 }
Esempio n. 16
0
        public DivisionsController(RealtorContext context)
        {
            this.db = context;
            if (!db.Divisions.Any())
            {
                db.Divisions.Add(new Division
                {
                    Name     = "First",
                    DateTime = DateTime.Now
                });
                db.Divisions.Add(new Division
                {
                    Name     = "Second",
                    DateTime = DateTime.Now,
                });

                db.SaveChanges();
            }
        }
Esempio n. 17
0
        //Добав квартиры
        public int AddApartment(string title, int area, int countRoom, int floor, int number, int price, string address)
        {
            Apartment ap = new Apartment();

            using (RealtorContext db = new RealtorContext())
            {
                ap.Title     = title;
                ap.Area      = area;
                ap.CountRoom = countRoom;
                ap.Floor     = floor;
                ap.Number    = number;
                ap.Price     = price;
                ap.Address   = address;

                db.Apartments.Add(ap);
                db.SaveChanges();

                return(db.Apartments.Where(ap2 => ap2.Title == title).Select(ap1 => ap1.Id).FirstOrDefault());
            }
        }
Esempio n. 18
0
 public HomeController(RealtorContext context)
 {
     db = context;
 }