Beispiel #1
0
 //מציגה את כל הערים
 public static List <CityDTO> getShowCity()
 {
     using (MoveilEntities db = new MoveilEntities())
     {
         return(CONVERTERES.CityConverters.ConvertCityListToDTO(db.NewCities.ToList()));
     }
 }
Beispiel #2
0
 //מציג את הערים המתאימות לכל אחד מהמחוזות
 public static List <CityDTO> getDistritoCode(int Code)
 {
     using (MoveilEntities db = new MoveilEntities())
     {
         return(CONVERTERES.CityConverters.ConvertCityListToDTO(db.NewCities.Where(t => t.DistritoCode == Code).ToList()));
     }
 }
Beispiel #3
0
 // מציגה את האנשי קשר לעיר המוימת לפי קוד העיר
 public static List <ContactDTO> getContact(int cityCode)
 {
     using (MoveilEntities db = new MoveilEntities())
     {
         return(CONVERTERES.ContactsConverters.ConvertContactsListToDTO(db.NewContacts.Where(t => t.CityCode == cityCode).ToList().OrderBy(x => Guid.NewGuid()).Take(2).ToList()));
     }
 }
Beispiel #4
0
 public static List <UserDTO> getAllUsers()
 {
     using (MoveilEntities db = new MoveilEntities())
     {
         return(CONVERTERES.UserConverters.ConvertUserListToDTO(db.Users.ToList()));
     }
 }
Beispiel #5
0
 public static List <DTO.ContactDTO> getShowContacts()
 {
     using (MoveilEntities db = new MoveilEntities())
     {
         return(CONVERTERES.ContactsConverters.ConvertContactsListToDTO(db.NewContacts.ToList()));
     }
 }
Beispiel #6
0
 public static UserDTO getUserCode(int code)
 {
     using (MoveilEntities db = new MoveilEntities())
     {
         return(CONVERTERES.UserConverters.ConvertUserToDTO(db.Users.FirstOrDefault(t => t.UserCode == code)));
     }
 }
Beispiel #7
0
 //מציג את המחוזות
 public static List <DistritoDTO> getDistrito()
 {
     using (MoveilEntities db = new MoveilEntities())
     {
         return(CONVERTERES.DistritoConverters.ConvertDistritoListToDTO(db.NewDistritoes.ToList()));
     }
 }
Beispiel #8
0
 public static List <SectorDTO> getAllSectors()
 {
     using (MoveilEntities db = new MoveilEntities())
     {
         return(CONVERTERES.SectorConverters.ConvertSectorListToDTO(db.Sectors.ToList()));
     }
 }
Beispiel #9
0
 public static List <CostoDTO> getAllCosto()
 {
     using (MoveilEntities db = new MoveilEntities())
     {
         return(CONVERTERES.CostoConverters.ConvertCostoListToDTO(db.NewCostoes.ToList()));
     }
 }
Beispiel #10
0
 public static void AddContacts(DTO.ContactDTO Contacts)
 {
     using (MoveilEntities db = new MoveilEntities())
     {
         db.NewContacts.Add(CONVERTERES.ContactsConverters.ConvertContactsToDAL(Contacts));
         db.SaveChanges();
     }
 }
Beispiel #11
0
 public static RepresentanteDTO getRepresentante(int code)
 {
     using (MoveilEntities db = new MoveilEntities())
     {
         //return CONVERTERES.CityConverters.ConvertCityToDTO(db.NewCities.Single(t => t.CityCode == cityCode));
         return(CONVERTERES.RepresentanteConverter.ConvertRepresentanteToDTO(db.Representantes.FirstOrDefault(t => t.RepresentanteCode == code)));
     }
 }
Beispiel #12
0
 // מציגה עיר אחת לפי הקוד שלה
 public static CityDTO getYourCity(int cityCode)
 {
     using (MoveilEntities db = new MoveilEntities())
     {
         //return CONVERTERES.CityConverters.ConvertCityToDTO(db.NewCities.Single(t => t.CityCode == cityCode));
         return(CONVERTERES.CityConverters.ConvertCityToDTO(db.NewCities.FirstOrDefault(t => t.CityCode == cityCode)));
     }
 }
 //מציגה את המלצות random 3
 public static List <RecommendationDTO> getShowRecommendation()
 {
     using (MoveilEntities db = new MoveilEntities())
     {
         return(CONVERTERES.RecommendationConverters.
                ConvertRecommendationListToDTO(db.Recommendations.ToList().
                                               OrderBy(x => Guid.NewGuid()).Take(3).ToList()));
     }
 }
Beispiel #14
0
 // הפונקציה בודקת אם המייל קיים כבר במערכת , אם כן מחזירה
 //תשובה שלילית ואם לא  חיובת יכול להשתמש במייל הזה
 public static bool SingInCheckUser(string email)
 {
     using (MoveilEntities db = new MoveilEntities())
     {
         var u = CONVERTERES.UserConverters.ConvertUserToDTO(db.Users.FirstOrDefault(t => t.Email.Equals(email)));
         if (u != null)
         {
             return(false);
         }
         return(true);
     }
 }
Beispiel #15
0
        // הפונקציה מחפשת קהולית מתאימות לפי מחזר, סטטוס משפחתי ויכולת כספי
        public static List <ComunityDTO> getComunity(PersonalStatusDTO per)
        {
            using (MoveilEntities db = new MoveilEntities())
            {
                if (per.QuienSoy == 2)
                {
                    var com = db.Comunities.Where(p => p.CostoCode == per.StatusEconomico &&
                                                  p.SectorCode == per.Religion && p.anciano == true).ToList();

                    if (com == null || com.Count == 0)
                    {
                        var com2 = db.Comunities.Where(p => p.CostoCode == per.StatusEconomico &&
                                                       p.anciano == true).ToList();

                        if (com == null || com.Count == 0)
                        {
                            return(CONVERTERES.ComunityConverters.ConvertComunityListToDTO
                                       (db.Comunities.Where(p => p.CostoCode == per.StatusEconomico &&
                                                            p.SectorCode == per.Religion).ToList()));
                        }
                        else
                        {
                            return(CONVERTERES.ComunityConverters.ConvertComunityListToDTO(com));
                        }
                    }

                    else
                    {
                        return(CONVERTERES.ComunityConverters.ConvertComunityListToDTO(com));
                    }
                }
                else
                {
                    var com =
                        db.Comunities.Where(p => p.CostoCode == per.StatusEconomico &&
                                            p.SectorCode == per.Religion).ToList();
                    if (com == null || com.Count == 0)
                    {
                        return(CONVERTERES.ComunityConverters.ConvertComunityListToDTO(
                                   db.Comunities.Where(p => p.SectorCode == per.Religion).ToList()));
                    }
                    else
                    {
                        return(CONVERTERES.ComunityConverters.ConvertComunityListToDTO(com));
                    }
                }
            }
        }
Beispiel #16
0
 //הפונקציה בודקת האם המשתמש קיים אם כן מחזיר תשובה חיובית אם לא שלילית
 public static UserDTO LogIn(LoginDTO log)
 {
     using (MoveilEntities db = new MoveilEntities())
     {
         var u = db.Users.FirstOrDefault(t => t.Email == log.Email && t.Password == log.Password);
         if (u == null)
         {
             return(null);
         }
         var u2 = CONVERTERES.UserConverters.ConvertUserToDTO(u);
         if (ConfigurationManager.AppSettings["UserName"] == log.Email && ConfigurationManager.AppSettings["Password"] == log.Password)
         {
             u2.IfDirective = true;
         }
         return(u2);
     }
 }
Beispiel #17
0
 public static List <CityDTO> getSearchCity(CityStatusDTO c)
 {
     using (MoveilEntities db = new MoveilEntities())
     {
         if (c.PrecioApt == 1)
         {
             if (c.Poblacion == 1)
             {
                 var com = db.NewCities.Where(p => p.NewApt >= 1400 &&
                                              p.DistritoCode == c.Distrito && p.NewPoblacion >= 200000).ToList();
                 if (com == null || com.Count == 0)
                 {
                     var com2 = db.NewCities.Where(p => p.NewApt >= 1400 &&
                                                   p.NewPoblacion >= 200000).ToList();
                     if (com2 == null || com.Count == 0)
                     {
                         return(CONVERTERES.CityConverters.ConvertCityListToDTO(db.NewCities.Where(p => p.NewApt >= 1400).ToList()));
                     }
                     return(CONVERTERES.CityConverters.ConvertCityListToDTO(com2));
                 }
                 return(CONVERTERES.CityConverters.ConvertCityListToDTO(com));
             }
             else if (c.Poblacion == 2)
             {
                 var com = db.NewCities.Where(p => p.NewApt >= 1400 &&
                                              p.DistritoCode == c.Distrito && p.NewPoblacion >= 100000 && p.NewPoblacion < 200000).ToList();
                 if (com == null || com.Count == 0)
                 {
                     var com2 = db.NewCities.Where(p => p.NewApt >= 1400 &&
                                                   p.NewPoblacion >= 100000 && p.NewPoblacion < 200000).ToList();
                     if (com2 == null || com.Count == 0)
                     {
                         return(CONVERTERES.CityConverters.ConvertCityListToDTO(db.NewCities.Where(p => p.NewApt >= 1400).ToList()));
                     }
                     return(CONVERTERES.CityConverters.ConvertCityListToDTO(com2));
                 }
                 return(CONVERTERES.CityConverters.ConvertCityListToDTO(com));
             }
             else
             {
                 var com = db.NewCities.Where(p => p.NewApt >= 1400 &&
                                              p.DistritoCode == c.Distrito && p.NewPoblacion < 100000).ToList();
                 if (com == null || com.Count == 0)
                 {
                     var com2 = db.NewCities.Where(p => p.NewApt >= 1400 &&
                                                   p.NewPoblacion < 100000).ToList();
                     if (com2 == null || com.Count == 0)
                     {
                         return(CONVERTERES.CityConverters.ConvertCityListToDTO(db.NewCities.Where(p => p.NewApt >= 1400).ToList()));
                     }
                     return(CONVERTERES.CityConverters.ConvertCityListToDTO(com2));
                 }
                 return(CONVERTERES.CityConverters.ConvertCityListToDTO(com));
             }
         }
         else if (c.PrecioApt == 2)
         {
             if (c.Poblacion == 1)
             {
                 var com = db.NewCities.Where(p => p.NewApt >= 1200 && p.NewApt < 1400 &&
                                              p.DistritoCode == c.Distrito && p.NewPoblacion >= 200000).ToList();
                 if (com == null || com.Count == 0)
                 {
                     var com2 = db.NewCities.Where(p => p.NewApt >= 1200 && p.NewApt < 1400 &&
                                                   p.NewPoblacion >= 200000).ToList();
                     if (com2 == null || com.Count == 0)
                     {
                         return(CONVERTERES.CityConverters.ConvertCityListToDTO(db.NewCities.Where(p => p.NewApt >= 1200 && p.NewApt < 1400).ToList()));
                     }
                     return(CONVERTERES.CityConverters.ConvertCityListToDTO(com2));
                 }
                 return(CONVERTERES.CityConverters.ConvertCityListToDTO(com));
             }
             else if (c.Poblacion == 2)
             {
                 var com = db.NewCities.Where(p => p.NewApt >= 1200 && p.NewApt < 1400 &&
                                              p.DistritoCode == c.Distrito && p.NewPoblacion >= 100000 && p.NewPoblacion < 200000).ToList();
                 if (com == null || com.Count == 0)
                 {
                     var com2 = db.NewCities.Where(p => p.NewApt >= 1200 && p.NewApt < 1400 &&
                                                   p.NewPoblacion >= 100000 && p.NewPoblacion < 200000).ToList();
                     if (com2 == null || com.Count == 0)
                     {
                         return(CONVERTERES.CityConverters.ConvertCityListToDTO(db.NewCities.Where(p => p.NewApt >= 1200 && p.NewApt < 1400).ToList()));
                     }
                     return(CONVERTERES.CityConverters.ConvertCityListToDTO(com2));
                 }
                 return(CONVERTERES.CityConverters.ConvertCityListToDTO(com));
             }
             else
             {
                 var com = db.NewCities.Where(p => p.NewApt >= 1200 && p.NewApt < 1400 &&
                                              p.DistritoCode == c.Distrito && p.NewPoblacion < 100000).ToList();
                 if (com == null || com.Count == 0)
                 {
                     var com2 = db.NewCities.Where(p => p.NewApt >= 1200 && p.NewApt < 1400 &&
                                                   p.NewPoblacion < 100000).ToList();
                     if (com2 == null || com.Count == 0)
                     {
                         return(CONVERTERES.CityConverters.ConvertCityListToDTO(db.NewCities.Where(p => p.NewApt >= 1200 && p.NewApt < 1400).ToList()));
                     }
                     return(CONVERTERES.CityConverters.ConvertCityListToDTO(com2));
                 }
                 return(CONVERTERES.CityConverters.ConvertCityListToDTO(com));
             }
         }
         else if (c.PrecioApt == 3)
         {
             if (c.Poblacion == 1)
             {
                 var com = db.NewCities.Where(p => p.NewApt >= 1000 && p.NewApt < 1200 &&
                                              p.DistritoCode == c.Distrito && p.NewPoblacion >= 200000).ToList();
                 if (com == null || com.Count == 0)
                 {
                     var com2 = db.NewCities.Where(p => p.NewApt < 1000 && p.NewApt > 1200 &&
                                                   p.NewPoblacion >= 200000).ToList();
                     if (com2 == null || com.Count == 0)
                     {
                         return(CONVERTERES.CityConverters.ConvertCityListToDTO(db.NewCities.Where(p => p.NewApt >= 1000 && p.NewApt < 1200).ToList()));
                     }
                     return(CONVERTERES.CityConverters.ConvertCityListToDTO(com2));
                 }
                 return(CONVERTERES.CityConverters.ConvertCityListToDTO(com));
             }
             if (c.Poblacion == 2)
             {
                 var com = db.NewCities.Where(p => p.NewApt >= 1000 && p.NewApt < 1200 &&
                                              p.DistritoCode == c.Distrito && p.NewPoblacion >= 100000 && p.NewPoblacion < 200000).ToList();
                 if (com == null || com.Count == 0)
                 {
                     var com2 = db.NewCities.Where(p => p.NewApt >= 1000 && p.NewApt < 1200 &&
                                                   p.NewPoblacion >= 100000 && p.NewPoblacion < 200000).ToList();
                     if (com2 == null || com.Count == 0)
                     {
                         return(CONVERTERES.CityConverters.ConvertCityListToDTO(db.NewCities.Where(p => p.NewApt >= 1000 && p.NewApt < 1200).ToList()));
                     }
                     return(CONVERTERES.CityConverters.ConvertCityListToDTO(com2));
                 }
                 return(CONVERTERES.CityConverters.ConvertCityListToDTO(com));
             }
             else
             {
                 var com = db.NewCities.Where(p => p.NewApt >= 1000 && p.NewApt < 1200 &&
                                              p.DistritoCode == c.Distrito && p.NewPoblacion < 100000).ToList();
                 if (com == null || com.Count == 0)
                 {
                     var com2 = db.NewCities.Where(p => p.NewApt >= 1000 && p.NewApt < 1200 &&
                                                   p.NewPoblacion < 100000).ToList();
                     if (com2 == null || com.Count == 0)
                     {
                         return(CONVERTERES.CityConverters.ConvertCityListToDTO(db.NewCities.Where(p => p.NewApt >= 1000 && p.NewApt < 1200).ToList()));
                     }
                     return(CONVERTERES.CityConverters.ConvertCityListToDTO(com2));
                 }
                 return(CONVERTERES.CityConverters.ConvertCityListToDTO(com));
             }
         }
         else
         {
             if (c.Poblacion == 1)
             {
                 var com = db.NewCities.Where(p => p.NewApt < 1000 &&
                                              p.DistritoCode == c.Distrito && p.NewPoblacion >= 200000).ToList();
                 if (com == null || com.Count == 0)
                 {
                     var com2 = db.NewCities.Where(p => p.NewApt < 1000 &&
                                                   p.NewPoblacion >= 200000).ToList();
                     if (com2 == null || com.Count == 0)
                     {
                         return(CONVERTERES.CityConverters.ConvertCityListToDTO(db.NewCities.Where(p => p.NewApt < 1000).ToList()));
                     }
                     return(CONVERTERES.CityConverters.ConvertCityListToDTO(com2));
                 }
                 return(CONVERTERES.CityConverters.ConvertCityListToDTO(com));
             }
             if (c.Poblacion == 2)
             {
                 var com = db.NewCities.Where(p => p.NewApt < 1000 &&
                                              p.DistritoCode == c.Distrito && p.NewPoblacion >= 100000 && p.NewPoblacion < 200000).ToList();
                 if (com == null || com.Count == 0)
                 {
                     var com2 = db.NewCities.Where(p => p.NewApt < 1000 &&
                                                   p.NewPoblacion >= 100000 && p.NewPoblacion < 200000).ToList();
                     if (com2 == null || com.Count == 0)
                     {
                         return(CONVERTERES.CityConverters.ConvertCityListToDTO(db.NewCities.Where(p => p.NewApt < 1000).ToList()));
                     }
                     return(CONVERTERES.CityConverters.ConvertCityListToDTO(com2));
                 }
                 return(CONVERTERES.CityConverters.ConvertCityListToDTO(com));
             }
             else
             {
                 var com = db.NewCities.Where(p => p.NewApt < 1000 &&
                                              p.DistritoCode == c.Distrito && p.NewPoblacion < 100000).ToList();
                 if (com == null || com.Count == 0)
                 {
                     var com2 = db.NewCities.Where(p => p.NewApt < 1000 &&
                                                   p.NewPoblacion < 100000).ToList();
                     if (com2 == null || com.Count == 0)
                     {
                         return(CONVERTERES.CityConverters.ConvertCityListToDTO(db.NewCities.Where(p => p.NewApt < 1000).ToList()));
                     }
                     return(CONVERTERES.CityConverters.ConvertCityListToDTO(com2));
                 }
                 return(CONVERTERES.CityConverters.ConvertCityListToDTO(com));
             }
         }
     }
 }