Exemplo n.º 1
0
        public void SaveImmobile(ImmobiliEntity imm)
        {
            try
            {
                using (var entities = new modelEntities())
                {
                    Immobili immobile = new Immobili();
                    immobile.AnnuncioPubblico = imm.AnnuncioPubblico;
                    immobile.Codice           = imm.Codice;
                    if (!imm.Prezzo.Equals(""))
                    {
                        immobile.Prezzo = Convert.ToInt32(imm.Prezzo);
                    }
                    immobile.Tipologia = imm.Tipologia;
                    immobile.Stato     = imm.Stato;
                    immobile.Provincia = imm.Provincia;
                    immobile.Comune    = imm.Comune;
                    immobile.Zona      = imm.Zona;
                    if (!string.IsNullOrEmpty(imm.Mq))
                    {
                        immobile.Mq = Convert.ToInt16(imm.Mq);
                    }
                    if (!string.IsNullOrEmpty(imm.Bagni))
                    {
                        immobile.Bagni = Convert.ToInt16(imm.Bagni);
                    }
                    immobile.Box       = imm.Box;
                    immobile.BoxDoppio = imm.Box;
                    immobile.PostoAuto = imm.PostoAuto;
                    immobile.MqTerreno = imm.MqTerreno;

                    if (!string.IsNullOrEmpty(imm.Camere))
                    {
                        immobile.Camere = Convert.ToInt16(imm.Camere);
                    }
                    immobile.Ascensore = imm.Ascensore;
                    if (!string.IsNullOrEmpty(imm.Locali))
                    {
                        immobile.Locali = Convert.ToInt16(imm.Locali);
                    }
                    if (!string.IsNullOrEmpty(imm.Riscaldamento))
                    {
                        immobile.Riscaldamento = imm.Riscaldamento;
                    }
                    immobile.Piano              = imm.Piano;
                    immobile.ClasseEnergetica   = imm.ClasseEnergetica;
                    immobile.Contratto          = imm.Contratto;
                    immobile.Descrizione        = imm.Descrizione;
                    immobile.DescrizioneBreve   = imm.DescrizioneBreve;
                    immobile.AnnuncioPubblico   = imm.AnnuncioPubblico;
                    immobile.AnnuncioInEvidenza = imm.AnnuncioInEvidenza;
                    entities.AddToImmobili(immobile);
                    entities.SaveChanges();
                }
            }
            catch (Exception e)
            {
                string errore = e.ToString();
            }
        }
Exemplo n.º 2
0
        public bool DeletePhoto(int idfoto)
        {
            bool ok = true;

            try
            {
                using (var entities = new modelEntities())
                {
                    Foto foto = (from l in entities.Foto
                                 where l.Id == idfoto
                                 select l).FirstOrDefault();
                    string pathfoto = foto.Path;
                    entities.DeleteObject(foto);
                    entities.SaveChanges();
                    File.Delete(pathfoto);
                    return(ok);
                }
            }
            catch (Exception e)
            {
                string errore = e.ToString();
                ok = false;
                return(ok);
            }
        }
Exemplo n.º 3
0
        public bool SetCopertina(int idfoto, string codice)
        {
            bool ok = true;

            try
            {
                using (var entities = new modelEntities())
                {
                    List <Foto> listafoto = (from p in entities.Foto
                                             where p.CodiceImmobile == codice
                                             select p).ToList();
                    foreach (Foto fo in listafoto)
                    {
                        fo.Copertina = 0;
                    }
                    Foto f = (from p in entities.Foto
                              where p.Id == idfoto
                              select p).First();
                    f.Copertina = 1;
                    entities.SaveChanges();
                }
            }
            catch (Exception e)
            {
                string errore = e.ToString();
                return(ok = false);
            }
            return(ok);
        }
Exemplo n.º 4
0
        public bool UpdateImmobile(ImmobiliEntity imm)
        {
            bool ok = true;

            try
            {
                using (var entities = new modelEntities())
                {
                    Immobili immobile = (from p in entities.Immobili
                                         where p.Codice == imm.Codice
                                         select p).First();
                    immobile.Codice = imm.Codice;
                    string prezzo = imm.Prezzo;
                    if (prezzo.Contains('.'))
                    {
                        prezzo = imm.Prezzo.Split('.')[0] + imm.Prezzo.Split('.')[1];
                    }
                    immobile.Prezzo             = Convert.ToInt32(prezzo);
                    immobile.Tipologia          = imm.Tipologia;
                    immobile.Stato              = imm.Stato;
                    immobile.Riscaldamento      = imm.Riscaldamento;
                    immobile.Provincia          = imm.Provincia;
                    immobile.Comune             = imm.Comune;
                    immobile.Zona               = imm.Zona;
                    immobile.Camere             = string.IsNullOrEmpty(imm.Camere) ? 0 : Convert.ToInt16(imm.Camere);
                    immobile.Mq                 = string.IsNullOrEmpty(imm.Mq) ? 0:Convert.ToInt16(imm.Mq);
                    immobile.Bagni              = string.IsNullOrEmpty(imm.Bagni) ? 0:Convert.ToInt16(imm.Bagni);
                    immobile.Box                = imm.Box;
                    immobile.Ascensore          = imm.Ascensore;
                    immobile.Locali             = string.IsNullOrEmpty(imm.Locali)?0:Convert.ToInt16(imm.Locali);
                    immobile.Piano              = imm.Piano;
                    immobile.ClasseEnergetica   = imm.ClasseEnergetica;
                    immobile.Contratto          = imm.Contratto;
                    immobile.Descrizione        = imm.Descrizione;
                    immobile.DescrizioneBreve   = imm.DescrizioneBreve;
                    immobile.AnnuncioPubblico   = imm.AnnuncioPubblico;
                    immobile.AnnuncioInEvidenza = imm.AnnuncioInEvidenza;
                    entities.SaveChanges();
                }
            }
            catch (Exception e)
            {
                string errore = e.ToString();
                return(ok = false);
            }
            return(ok);
        }
Exemplo n.º 5
0
        public void SaveCollaborazioni(CollaborazioniEntity coll)
        {
            try
            {
                using (var entities = new modelEntities())
                {
                    Collaborazioni collaborazioni = new Collaborazioni();

                    collaborazioni.Descrizione = coll.Descrizione;
                    collaborazioni.Path        = coll.Path;
                    entities.AddToCollaborazioni(collaborazioni);
                    entities.SaveChanges();
                }
            }
            catch (Exception e)
            {
                string errore = e.ToString();
            }
        }
Exemplo n.º 6
0
 public void SavePhoto(FotoEntity photo)
 {
     try
     {
         using (var entities = new modelEntities())
         {
             Foto foto = new Foto();
             foto.Descrizione    = photo.Descrizione;
             foto.Path           = photo.Path;
             foto.Copertina      = 0;
             foto.CodiceImmobile = photo.CodiceImmobile;
             entities.AddToFoto(foto);
             entities.SaveChanges();
         }
     }
     catch (Exception e)
     {
         string errore = e.ToString();
     }
 }
Exemplo n.º 7
0
        public bool SetInEvidenza(string codice)
        {
            bool ok = true;

            try
            {
                using (var entities = new modelEntities())
                {
                    Immobili immobile = (from p in entities.Immobili
                                         where p.Codice == codice
                                         select p).First();
                    immobile.AnnuncioInEvidenza = true;
                    entities.SaveChanges();
                }
            }
            catch (Exception e)
            {
                string errore = e.ToString();
                return(ok = false);
            }
            return(ok);
        }
Exemplo n.º 8
0
        public bool UpdatePhoto(int idfoto, string descrizione)
        {
            bool ok = true;

            try
            {
                using (var entities = new modelEntities())
                {
                    Foto f = (from p in entities.Foto
                              where p.Id == idfoto
                              select p).First();
                    f.Descrizione = descrizione;
                    entities.SaveChanges();
                }
            }
            catch (Exception e)
            {
                string errore = e.ToString();
                return(ok = false);
            }
            return(ok);
        }
Exemplo n.º 9
0
        public bool DeleteImmobile(string codice)
        {
            bool ok = true;

            try
            {
                using (var entities = new modelEntities())
                {
                    Immobili imm = (from l in entities.Immobili
                                    where l.Codice == codice
                                    select l).FirstOrDefault();
                    entities.DeleteObject(imm);
                    entities.SaveChanges();
                    return(ok);
                }
            }
            catch (Exception e)
            {
                string errore = e.ToString();
                ok = false;
                return(ok);
            }
        }
Exemplo n.º 10
0
        public bool DeleteCollaborazioni(int id)
        {
            bool ok = true;

            try
            {
                using (var entities = new modelEntities())
                {
                    Collaborazioni imm = (from l in entities.Collaborazioni
                                          where l.Id == id
                                          select l).FirstOrDefault();
                    entities.DeleteObject(imm);
                    entities.SaveChanges();
                    return(ok);
                }
            }
            catch (Exception e)
            {
                string errore = e.ToString();
                ok = false;
                return(ok);
            }
        }
Exemplo n.º 11
0
        public bool UpdateCollaborazioni(CollaborazioniEntity coll)
        {
            bool ok = true;

            try
            {
                using (var entities = new modelEntities())
                {
                    Collaborazioni col = (from p in entities.Collaborazioni
                                          where p.Id == coll.Id
                                          select p).First();
                    col.Descrizione = coll.Descrizione;

                    entities.SaveChanges();
                }
            }
            catch (Exception e)
            {
                string errore = e.ToString();
                return(ok = false);
            }
            return(ok);
        }