Ejemplo n.º 1
0
 public Entities.Case ReadCase(int ID)
 {
     using (var database = new EstateBrokerContext())
     {
         return((Entities.Case)CaseFactory.CreateCase(database.Cases.Find(ID)));
     }
 }
Ejemplo n.º 2
0
 public Entities.Realtor ReadRealtor(int ID)
 {
     using (var database = new EstateBrokerContext())
     {
         return((Entities.Realtor)RealtorFactory.CreateRealtor(database.Realtors.Find(ID)));
     }
 }
Ejemplo n.º 3
0
 public void DeleteRealtor(int ID)
 {
     using (var database = new EstateBrokerContext())
     {
         database.Realtors.Remove(database.Realtors.Find(ID));
         database.SaveChanges();
     }
 }
Ejemplo n.º 4
0
 public int ReturnRealtorIDOnCase(int ID)
 {
     using (var database = new EstateBrokerContext())
     {
         Database.Case tempCase = database.Cases.Find(ID);
         return(tempCase.RealtorID);
     }
 }
Ejemplo n.º 5
0
 public void UpdateRealtor(int ID, string name, string phoneNR)
 {
     using (var database = new EstateBrokerContext())
     {
         Realtor realtor = database.Realtors.Find(ID);
         realtor.Name    = name;
         realtor.PhoneNR = phoneNR;
         database.SaveChanges();
     }
 }
Ejemplo n.º 6
0
        public void CreateRealtor(string name, string phoneNR)
        {
            var database = new EstateBrokerContext();

            var realtor = new Realtor()
            {
                Name    = name,
                PhoneNR = phoneNR
            };

            database.Realtors.Add(realtor);
            database.SaveChanges();
        }
Ejemplo n.º 7
0
        public List <Entities.Case> ReadAllCases()
        {
            List <Entities.Case> caseList = new List <Entities.Case>();

            using (var database = new EstateBrokerContext())
            {
                foreach (var Case in database.Cases)
                {
                    caseList.Add((Entities.Case)CaseFactory.CreateCase(Case));
                }
                return(caseList);
            }
        }
Ejemplo n.º 8
0
        public int CreateCase(DateTime creationDate, double price, int realtorID)
        {
            using (var database = new EstateBrokerContext())
            {
                var workingCase = new Case()
                {
                    CreationDate = creationDate,
                    Price        = price,
                    RealtorID    = realtorID
                };

                database.Cases.Add(workingCase);
                database.SaveChanges();
                return(workingCase.CaseID);
            }
        }
Ejemplo n.º 9
0
        public List <Entities.Case> ReadAPreDefinedNumberOfCasesWithNoRealtor(int number)
        {
            List <Entities.Case> caseList = new List <Entities.Case>();

            using (var database = new EstateBrokerContext())
            {
                foreach (var Case in database.Cases)
                {
                    if (Case.RealtorID == 1 && caseList.Count != number)
                    {
                        caseList.Add((Entities.Case)CaseFactory.CreateCase(Case));
                    }
                }
                return(caseList);
            }
        }
Ejemplo n.º 10
0
 public bool UpdateCase(int ID, DateTime creationDate, DateTime?closedDate, double price, int realtorID)
 {
     try
     {
         using (var database = new EstateBrokerContext())
         {
             Database.Case workingCase = database.Cases.Find(ID);
             workingCase.CreationDate = creationDate;
             workingCase.ClosedDate   = closedDate;
             workingCase.Price        = price;
             workingCase.RealtorID    = realtorID;
             database.SaveChanges();
         }
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Ejemplo n.º 11
0
        public List <Entities.Case> ReadCasesInPostalCode(int postalCode)
        {
            using (var database = new EstateBrokerContext())
            {
                List <Entities.Case>     cases      = new List <Entities.Case>();
                List <Database.Property> properties = new List <Database.Property>();

                if (database.Properties.Any(s => s.PostalCode == postalCode) == true)
                {
                    properties = database.Properties.Where(s => s.PostalCode == postalCode).ToList();
                }

                foreach (var item in properties)
                {
                    cases.Add((Entities.Case)CaseFactory.CreateCase(database.Cases.Find(item.CaseID)));
                }

                database.SaveChanges();

                return(cases);
            }
        }