示例#1
0
 void clickDelete(int idEstate)
 {
     dbContext.Transactions.Remove(dbContext.Transactions.Where(t => t.Reference == idEstate).FirstOrDefault());
     dbContext.Estates.Remove(dbContext.Estates.Find(idEstate));
     dbContext.SaveChanges();
     updateContent();
 }
示例#2
0
        public ModifyTransacViewModel(Window parent, int idEstate)
        {
            Parent         = parent;
            Reference      = idEstate;
            estateToModify = dbContext.Estates.Find(Reference);
            People         = new ObservableCollection <Person>(dbContext.Persons.ToList());
            loadFields(idEstate);
            if (People.Count != 0)
            {
                return;
            }

            for (int i = 0; i < 10; i++)
            {
                Person toAdd = GeneratePerson();
                dbContext.Add(toAdd);
            }
            dbContext.SaveChanges();
            loadFields(idEstate);
        }
示例#3
0
        void clickAdd()
        {
            Estate res = dbContext.Estates.Find(Reference);

            if (res != null || Reference == 0)
            {
                System.Windows.MessageBox.Show("Cette référence est déjà attribuée !");
                return;
            }
            if (Commercial == null || Owner == null || Client == null)
            {
                System.Windows.MessageBox.Show("Il faut remplir au minimum toutes les combosBox !");
                return;
            }

            try
            {
                Photo.Person = Commercial;
            }
            catch (Exception e)
            {
                System.Windows.MessageBox.Show("Il faut au moins mettre une photo !");
                return;
            }

            Estate estateToBeAdded = new Estate()
            {
                Reference            = Reference,
                FloorCount           = FloorCount,
                RoomsCount           = RoomsCount,
                BathroomCount        = BathroomCount,
                Surface              = Surface,
                Address              = Address,
                ZipCode              = ZipCode,
                City                 = City,
                FloorNumber          = FloorNumber,
                CarbonFootPrint      = CarbonFootPrint,
                Type                 = EstateType,
                EnergeticPerformance = EnergeticPerformance,
                CommercialId         = Commercial.Id,
                Photos               = new List <Photo>
                {
                    Photo
                }
            };

            Transaction transactionToBeAdded = new Transaction()
            {
                Title           = Title,
                Description     = Description,
                PublicationDate = DateTime.Now.AddMonths(-1),
                Type            = TransacType,
                Price           = Price,
                Fees            = Fees,
                Estate          = estateToBeAdded,
                Owner           = Owner,
                Client          = Client
            };


            dbContext.Estates.Add(estateToBeAdded);
            dbContext.Transactions.Add(transactionToBeAdded);
            dbContext.SaveChanges();

            Parent.Close();
        }