Example #1
0
        public ActionResult List(foto entity, String message, int idJuri = 0)
        {
            ViewData["message"] = message;
            ViewData["Juri"]    = entity.juri;
            ViewData["idFoto"]  = entity.id_foto;

            if (idJuri == 0)
            {
                idJuri             = entity.fk_id_juri;
                ViewData["idJuri"] = entity.fk_id_juri;
            }
            else
            {
                ViewData["idJuri"] = idJuri;
            }

            var imagesModel = new ImageGallery();

            if (Directory.Exists(Server.MapPath("~/Documentos/Fotos/" + idJuri)))
            {
                var imageFiles = Directory.GetFiles(Server.MapPath("~/Documentos/Fotos/" + idJuri));
                foreach (var item in imageFiles)
                {
                    if (item.IndexOf("Thumbs.db") < 0)
                    {
                        imagesModel.ImageList.Add(Path.GetFileName(item));
                    }
                }
            }

            return(View(imagesModel));
        }
Example #2
0
 public void Save(foto entity)
 {
     DataModel.Entry(entity).State = entity.id_foto == 0 ?
                                     EntityState.Added :
                                     EntityState.Modified;
     DataModel.SaveChanges();
 }
Example #3
0
 public void Post(foto ft)
 {
     if (ModelState.IsValid)
     {
         myEntity.fotos.Add(ft);
         myEntity.SaveChanges();
     }
 }
Example #4
0
        public foto GetFotoById(string path)
        {
            foto foto = new foto();

            foto = GetOne(path);

            return(foto);
        }
Example #5
0
 private void checkedListBoxControl1_Enter(object sender, EventArgs e)
 {
     if (checkedListBoxControl1.ItemCount > 0)
     {
         foto f = (foto)checkedListBoxControl1.SelectedItem;
         pictureBox1.Image = (Bitmap)((new ImageConverter()).ConvertFrom(f.foto1));
     }
 }
Example #6
0
        public ActionResult DeleteConfirmed(string id)
        {
            foto foto = db.foto.Find(id);

            db.foto.Remove(foto);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Example #7
0
 public ActionResult Edit([Bind(Include = "coordinaten,foto1,datum")] foto foto)
 {
     if (ModelState.IsValid)
     {
         db.Entry(foto).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(foto));
 }
Example #8
0
        public ActionResult Create([Bind(Include = "coordinaten,foto1,datum")] foto foto)
        {
            if (ModelState.IsValid)
            {
                db.foto.Add(foto);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(foto));
        }
Example #9
0
        public bool validate(foto entity)
        {
            bool retorno = false;

            if (string.IsNullOrEmpty(entity.path))
            {
                ModelState.AddModelError("path", "Escolha uma ou mais fotos para publicar.");
                retorno = true;
            }

            return(retorno);
        }
Example #10
0
        private void simpleButton1_Click(object sender, EventArgs e)
        {
            DialogResult result = MessageBox.Show("Seguro que desea modificar los datos de la propiedad?", "Cambio de Datos de Propiedad", MessageBoxButtons.YesNo);

            if (result == DialogResult.Yes)
            {
                propiedadAModificar.nombre       = nombreBox.Text;
                propiedadAModificar.ubicaciòn    = ubicacionBox.Text;
                propiedadAModificar.ciudad       = ciudadBox.Text;
                propiedadAModificar.provincia    = provinciaBox.Text;
                propiedadAModificar.pais         = paisBox.Text;
                propiedadAModificar.tipo         = tipoBox.Text;
                propiedadAModificar.montoReserva = decimal.Parse(boxMonto.Text);
                propiedadAModificar.habitaciones = decimal.ToInt32(cantHabitaciones.Value);

                using (ContextoEntity conexion = new ContextoEntity())
                {
                    var aux = conexion.Propiedads.Where(p => p.id != propiedadAModificar.id).ToList();

                    if (mismaDir(aux, propiedadAModificar))
                    {
                        MessageBox.Show("La propiedad no puede tener una direccion completa (ubicacion + ciudad + provincia + pais) identica a una ya agregada.");
                        return;
                    }
                    if (propiedadAModificar.nombre == "" || propiedadAModificar.ubicaciòn == "" || propiedadAModificar.ciudad == "" ||
                        propiedadAModificar.provincia == "" || propiedadAModificar.pais == "" || propiedadAModificar.tipo == "")
                    {
                        MessageBox.Show("Ningun campo puede estar vacio.");
                        return;
                    }
                    if (fotos != null)
                    {
                        label3.Visible = true;
                        foreach (byte[] b in fotos)
                        {
                            foto ima = new foto(propiedadAModificar.id, b);
                            conexion.fotos.Add(ima);
                        }
                    }
                    fotos = null;
                    conexion.Entry(propiedadAModificar).State = System.Data.Entity.EntityState.Modified;
                    conexion.SaveChanges();
                    Sesion.vistaPrincipalDeAdmin.vuelveDeModificarPropiedad();
                    this.Close();
                }
            }
            else if (result == DialogResult.No)
            {
                this.Close();
            }
        }
Example #11
0
        public ActionResult Edit(string id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            foto foto = db.foto.Find(id);

            if (foto == null)
            {
                return(HttpNotFound());
            }
            return(View(foto));
        }
Example #12
0
 public void Put(foto ft)
 {
     if (ModelState.IsValid)
     {
         myEntity.Entry(ft).State = EntityState.Modified;
         try
         {
             myEntity.SaveChanges();
         }
         catch (Exception)
         {
             throw;
         }
     }
 }
Example #13
0
        public void Delete(int id)
        {
            foto dlt = myEntity.fotos.Find(id);

            if (dlt != null)
            {
                try
                {
                    myEntity.fotos.Remove(dlt);
                    myEntity.SaveChanges();
                }
                catch (Exception)
                {
                    throw;
                }
            }
        }
Example #14
0
        public async Task <FotoEntity> Find(string tipo, int id)
        {
            FotoEntity Foto = new FotoEntity();
            findInstanciaFotoResponse Response = await this.Service.findInstanciaFotoAsync(tipo, id);

            if (Response.@return != null)
            {
                foto f = [email protected]();

                Foto.Id_Foto        = (int)[email protected]().idFoto;
                Foto.Nombre_Archivo = "http://localhost:8080" + [email protected]().nombreArchivo;
                Foto.Orden          = Int32.Parse([email protected]().orden);
                Foto.Titulo         = [email protected]().titulo;
                //Foto.Representante = await this.UsuarioService.Find((int)[email protected]);
                //Foto.Centro = await this.CentroService.Find((int)[email protected]);
            }
            return(Foto);
        }
Example #15
0
        public ActionResult UploadImage(foto foto)
        {
            if (Request.Files.Count != 0)
            {
                if (!Directory.Exists(Server.MapPath("~/Documentos/Fotos/" + Session["idJuri"])))
                {
                    Directory.CreateDirectory(Server.MapPath("~/Documentos/Fotos/" + Session["idJuri"]));
                }
                if (validate(foto))
                {
                    return(View(foto));
                }

                HttpFileCollectionBase hfc   = Request.Files;
                List <foto>            fotos = new List <foto>();

                for (int i = 0; i < hfc.Count; i++)
                {
                    HttpPostedFileBase file = hfc[i];
                    int    fileSize         = file.ContentLength;
                    string fileName         = file.FileName;

                    file.SaveAs(Server.MapPath("~/Documentos/Fotos/" + Session["idJuri"] + "/" + fileName));

                    ImageGallery imageGallery = new ImageGallery();
                    imageGallery.ID        = Guid.NewGuid();
                    imageGallery.Name      = fileName;
                    imageGallery.ImagePath = "~/Documentos/Fotos/" + Session["idJuri"] + "/" + fileName;

                    foto salvafoto = new foto();
                    salvafoto.fk_id_juri = int.Parse(Session["idJuri"].ToString());
                    salvafoto.path       = imageGallery.ImagePath;
                    fotos.Add(salvafoto);
                }

                FotoRepository.Create(fotos);
                return(RedirectToAction("List", new { message = "Fotos publicadas com sucesso!", idJuri = int.Parse(Session["idJuri"].ToString()) }));
            }

            return(View(foto));
        }
Example #16
0
        public ActionResult Delete(string path, foto foto)
        {
            try
            {
                foto = FotoRepository.GetFotoById(path);

                if (!FileServerHelper.DeleteFile(Server.MapPath(foto.path)))
                {
                    throw new Exception("Não foi possível salvar o arquivo");
                }
                else
                {
                    FotoRepository.Delete(foto);
                }

                return(RedirectToAction("List", new { message = "Dados excluídos com sucesso!" }));
            }
            catch
            {
                return(View());
            }
        }
 private void crearButton2_Click(object sender, EventArgs e)
 {
     if ((boxProvincia.Text.Length > 0) && (textTipo.Text.Length > 0) && (textUbicacion.Text.Length > 0) && (boxNombre.Text.Length > 0) && (boxCiudad.Text.Length > 0) && (boxPais.Text.Length > 0))
     {
         if (decimal.Parse(boxMonto.Text) > 0)
         {
             casa = new Propiedad(boxNombre.Text, boxCiudad.Text, boxProvincia.Text, boxPais.Text, textTipo.Text, textUbicacion.Text, decimal.ToInt32(cantHabitaciones.Value), decimal.Parse(boxMonto.Text), Sesion.admin.token, DateTime.Today);
             if (fotito != null)
             {
                 foreach (byte[] b in fotito)
                 {
                     foto ima = new foto(casa.id, b);
                     casa.fotos.Add(ima);
                 }
             }
             else
             {
                 casa.fotos = null;
             }
             if (casa.guardarAltaEnBD())
             {
                 MessageBox.Show("Se dio de alta a la propiedad con éxito");
                 Sesion.vistaPrincipalDeAdmin.ocultarFormsderivados();
                 this.limpiarCampos();
             }
         }
         else
         {
             MessageBox.Show("El monto no puede ser negativo");
         }
     }
     else
     {
         MessageBox.Show("Faltan completar campos");
     }
 }
Example #18
0
 public void Delete(foto entity)
 {
     DataModel.foto.Remove(entity);
     DataModel.SaveChanges();
 }
Example #19
0
        public foto Get(int id)
        {
            foto ft = myEntity.fotos.Find(id);

            return(ft);
        }