Пример #1
0
 public void DeleteBuyer(Buyer buyer)
 {
     using (var ctx = new SystemContext())
     {
         ctx.Buyers.Attach(buyer);
         ctx.Buyers.Remove(buyer);
         ctx.SaveChanges();
     }
 }
Пример #2
0
        public void ReadTest()
        {
            //No properties does need to be created before the property itself
            //Create the property itself
            Buyer johnDoe = new Buyer() { Name = "John Doe", Address = "Sofiendalsvej 60", ZipCode = "9000", Email = "*****@*****.**", Misc = "Her skal stå noget", Mobile = "51203985", Phone = "51203985" };

            //Save it to the database
            bCtr.InsertBuyer(johnDoe);

            //Get property from database and assert not null
            Assert.IsNotNull(bCtr.GetBuyerByPhone("51203985"));
            bCtr.DeleteBuyer(johnDoe);
        }
Пример #3
0
        public void CreateTest()
        {
            //Create the user itself
            Buyer johnDoe = new Buyer() { Name = "John Doe", Address = "Sofiendalsvej 60", Email = "*****@*****.**", Misc = "Her skal stå noget", Mobile = "51203985", Phone = "51203985" };

            //Save it to the database and get amount of properties in db before and after save
            int CountDB = bCtr.GetAllBuyers().ToList().Count;
            bCtr.InsertBuyer(johnDoe);
            int CountDBAfter = bCtr.GetAllBuyers().ToList().Count;
            //Compare Properties. Maybe use conditions other than Adress?
            Assert.AreEqual<int>(CountDBAfter, CountDB + 1);
            bCtr.DeleteBuyer(johnDoe);
        }
Пример #4
0
        public void DeleteTest()
        {
            //Create properties that are part of user.
            //Create the user itself
            Buyer johnDoe = new Buyer() { Name = "John Doe", Address = "Sofiendalsvej 60", ZipCode = "9000", Email = "*****@*****.**", Misc = "Her skal stå noget", Mobile = "51203985", Phone = "51203985" };

            //Save it to the database
            bCtr.InsertBuyer(johnDoe);

            //Delete it again
            bCtr.DeleteBuyer(johnDoe);

            //Try to retrieve the deleted user again, and assert it is null.
            Buyer b = bCtr.GetBuyerByPhone(johnDoe.Phone);
            Assert.IsNull(b);
        }
Пример #5
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();
     }
 }
Пример #6
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();
     }
 }
Пример #7
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();
     }
 }
Пример #8
0
 public void InsertBuyer(Buyer buyer)
 {
     using (var ctx = new SystemContext())
     {
         ctx.Buyers.Add(buyer);
         ctx.SaveChanges();
     }
 }
Пример #9
0
 public void InsertAppointment(Appointment appointment, Buyer buyer, Seller seller)
 {
     dbApp.InsertAppointment(appointment, buyer, seller);
 }
Пример #10
0
 public void DeleteBuyer(Buyer buyer)
 {
     bCtr.DeleteBuyer(buyer);
 }
Пример #11
0
 public void UpdateBuyerSingle(Buyer buyer)
 {
     bCtr.UpdateBuyer(buyer);
 }
Пример #12
0
 public void DeleteBuyer(Buyer buyer)
 {
     dbBuy.DeleteBuyer(buyer);
 }
Пример #13
0
 public void InsertBuyer(Buyer buyer)
 {
     bCtr.InsertBuyer(buyer);
 }
Пример #14
0
        public void UpdateTest()
        {
            //Create the user itself
            List<Location> locations = new List<Location>();

            Buyer johnDoe = new Buyer() { Name = "John Doe", Address = "Sofiendalsvej 60", ZipCode = "9000", Email = "*****@*****.**", Misc = "Her skal stå noget", Mobile = "51203985", Phone = "51203985", Locations = locations };
            //Save it to the database
            bCtr.InsertBuyer(johnDoe);
            //Change the user:
            List<Property> properties = new List<Property>();
            bCtr.UpdateBuyer(johnDoe, properties, johnDoe.Name, johnDoe.Address, johnDoe.ZipCode, "112", johnDoe.Mobile, johnDoe.Email, johnDoe.Misc, johnDoe.EstateType, johnDoe.MinPrice, johnDoe.MaxPrice, johnDoe.LotSizeMin, johnDoe.LotSizeMax, johnDoe.ProbertySizeMin, johnDoe.ProbertySizeMax, johnDoe.DesiredRoomsMin, johnDoe.DesiredRoomsMax,
                johnDoe.Locations.ToList(), johnDoe.OtherPref, johnDoe.ContactAllowedByBoligOne, johnDoe.ContactAllowedByReal, johnDoe.AllowedEmailSpam, johnDoe.InRKI, johnDoe.BuyerApproved, johnDoe.Bank, johnDoe.OwnesHouse, johnDoe.LivesForRent);

            //Test the assertion

            Assert.IsNotNull(bCtr.GetBuyerByPhone("112"));
            bCtr.DeleteBuyer(johnDoe);
        }
Пример #15
0
 public void InsertBuyer(Buyer buyer)
 {
     dbBuy.InsertBuyer(buyer);
 }
Пример #16
0
 public void UpdateBuyer(Buyer buyer, List<Property> properties, string name, string address, string zipCode, string phone, string mobil, string email, string misc, string estateType, double minPrice, double maxPrice, double lotSizeMin, double lotSizeMax, double probertySizeMin, double probertySizeMax, double desiredRoomsMin, double desiredRoomsMax, List<ModelLayer.Location> desiredLocations, string otherPref, bool contactAllowedByBoligOne, bool contactAllowedByReal, bool allowedEmailSpam, bool inRKI, bool buyerApproved, string bank, bool ownesHouse, bool livesForRent)
 {
     bCtr.UpdateBuyer(buyer, properties, name, address, zipCode, phone, mobil, email,
                      misc, estateType, minPrice, maxPrice, lotSizeMin, lotSizeMax,
                      probertySizeMin, probertySizeMax, desiredRoomsMin, desiredRoomsMax,
                      desiredLocations, otherPref, contactAllowedByBoligOne, contactAllowedByReal,
                      allowedEmailSpam, inRKI, buyerApproved, bank, ownesHouse, livesForRent);
 }
Пример #17
0
 public void UpdateBuyer(Buyer buyer)
 {
     dbBuy.UpdateBuyer(buyer);
 }