Ejemplo n.º 1
0
 public void DeleteSeller(Seller seller)
 {
     using (var ctx = new SystemContext())
     {
         ctx.Sellers.Attach(seller);
         ctx.Sellers.Remove(seller);
         ctx.SaveChanges();
     }
 }
Ejemplo n.º 2
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;
 }
Ejemplo n.º 3
0
        public void CreateTest()
        {
            //Create necessary list for seller.
            List<Property> propertyList = new List<Property>();

            //Create the seller itself.
            Seller sellDatHouse = new Seller() { Name = "Mr. Sell D. House", Address = "Sofiendalsvej 60", Email = "*****@*****.**", Misc = "Han vil virkelig gerne have sit hus solgt", Mobile = "40528283", Phone = "40528283", ZipCode = "9000", Properties = propertyList };

            //Save it to the database
            int CountDB = sCtr.GetAllSellers().ToList().Count;
            sCtr.InsertSeller(sellDatHouse);
            int CountDBAfter = sCtr.GetAllSellers().ToList().Count;

            //Compare sellers.
            Assert.AreEqual<int>(CountDBAfter, CountDB + 1);
            sCtr.DeleteSeller(sellDatHouse);
        }
Ejemplo n.º 4
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();
     }
 }
Ejemplo n.º 5
0
        public void DeleteTest()
        {
            //Create necessary list for seller.
            List<Property> propertyList = new List<Property>();

            //Create the seller itself.
            Seller sellDatHouse = new Seller() { Name = "Mr. Sell D. House", Address = "Sofiendalsvej 60", Email = "*****@*****.**", Misc = "Han vil virkelig gerne have sit hus solgt", Mobile = "40528283", Phone = "40528283", ZipCode = "9000", Properties = propertyList };

            //Save it to the database
            sCtr.InsertSeller(sellDatHouse);

            //Delete it again
            sCtr.DeleteSeller(sellDatHouse);

            //Try to retrieve the deleted seller again, and assert it is null.
            Seller sellDatHouseNew = sCtr.GetSellerByPhone(sellDatHouse.Mobile);
            Assert.IsNull(sellDatHouseNew);
        }
Ejemplo n.º 6
0
 public void DeleteSeller(Seller seller)
 {
     sCtr.DeleteSeller(seller);
 }
Ejemplo n.º 7
0
 public void AddPropertyToSeller(Seller seller, Property property)
 {
     sCtr.AddPropertyToSeller(seller, property);
 }
Ejemplo n.º 8
0
 public void UpdateSellerSingle(Seller seller)
 {
     sCtr.UpdateSeller(seller);
 }
Ejemplo n.º 9
0
 public void UpdateSeller(Seller seller, List<Property> properties, string name, string address, string zipCode, string phone, string mobil, string email, string misc)
 {
     sCtr.UpdateSeller(seller, properties, name, address, zipCode, phone, mobil, email, misc);
 }
Ejemplo n.º 10
0
 public void InsertSeller(Seller seller)
 {
     sCtr.InsertSeller(seller);
 }
Ejemplo n.º 11
0
 public List<Property> GetAllPropertiesFromSeller(Seller seller)
 {
     return sCtr.GetAllProperties(seller);
 }
Ejemplo n.º 12
0
        public void UpdateSeller(Seller seller, List<Property> properties, string name, string address, string zipCode, string phone, string mobil, string email, string misc)
        {
            using (var ctx = new SystemContext())
            {
                Seller s = ctx.Sellers.Where(x => x.Id == seller.Id).SingleOrDefault();
                s.Name = name;
                s.Properties = properties;
                s.Address = address;
                s.ZipCode = zipCode;
                s.Phone = phone;
                s.Mobile = mobil;
                s.Email = email;
                s.Misc = misc;

                ctx.Entry(s).State = System.Data.Entity.EntityState.Modified;
                ctx.SaveChanges();
            }
        }
Ejemplo n.º 13
0
 public void DeleteSeller(Seller seller)
 {
     dbSel.DeleteSeller(seller);
 }
Ejemplo n.º 14
0
 public void InsertSeller(Seller seller)
 {
     using (var ctx = new SystemContext())
     {
         ctx.Sellers.Add(seller);
         ctx.SaveChanges();
     }
 }
Ejemplo n.º 15
0
        public void UpdateTest()
        {
            //Create necessary list for seller.
            List<Property> propertyList = new List<Property>();

            //Create the seller itself.
            Seller sellDatHouse = new Seller() { Name = "Mr. Sell D. House", Address = "Sofiendalsvej 60", Email = "*****@*****.**", Misc = "Han vil virkelig gerne have sit hus solgt", Mobile = "40528283", Phone = "40528283", ZipCode = "9000", Properties = propertyList };

            //Save it to the database
            sCtr.InsertSeller(sellDatHouse);

            //Change the seller:
            sCtr.UpdateSeller(sellDatHouse, propertyList, sellDatHouse.Name, sellDatHouse.Address, sellDatHouse.ZipCode, "112", sellDatHouse.Mobile, sellDatHouse.Email, sellDatHouse.Misc);

            //Test the assertion
            Assert.IsNotNull(sCtr.GetSellerByPhone("112"));
            sCtr.DeleteSeller(sellDatHouse);
        }
Ejemplo n.º 16
0
 public List<Property> GetAllProperties(Seller seller)
 {
     return dbSel.GetAllProperties(seller);
 }
Ejemplo n.º 17
0
 public void InsertSeller(Seller seller)
 {
     dbSel.InsertSeller(seller);
 }
Ejemplo n.º 18
0
 public void UpdateSeller(Seller seller)
 {
     using (var ctx = new SystemContext())
     {
         Seller dbSeller = ctx.Sellers.Find(seller.Id);
         ctx.Entry(dbSeller).CurrentValues.SetValues(seller);
         ctx.SaveChanges();
     }
 }
Ejemplo n.º 19
0
 public void InsertAppointment(Appointment appointment, Buyer buyer, Seller seller)
 {
     dbApp.InsertAppointment(appointment, buyer, seller);
 }
Ejemplo n.º 20
0
        public void ReadTest()
        {
            //Create necessary list for seller.
            List<Property> propertyList = new List<Property>();

            //Create the seller itself.
            Seller sellDatHouse = new Seller() { Name = "Mr. Sell D. House", Address = "Sofiendalsvej 60", Email = "*****@*****.**", Misc = "Han vil virkelig gerne have sit hus solgt", Mobile = "40528283", Phone = "40528283", ZipCode = "9000", Properties = propertyList };

            //Save it to the database
            sCtr.InsertSeller(sellDatHouse);

            //Compare sellers.
            Assert.IsNotNull(sCtr.GetSellerByPhone("40528283"));
            sCtr.DeleteSeller(sellDatHouse);
        }
Ejemplo n.º 21
0
 public void AddPropertyToSeller(Seller seller, Property property)
 {
     seller.Properties.Add(property);
 }
Ejemplo n.º 22
0
 public void UpdateSeller(Seller seller)
 {
     dbSel.UpdateSeller(seller);
 }