public ActionResult DeleteConfirmed(string id)
        {
            EstadoLote estadoLote = db.EstadoLote.Find(id);

            db.EstadoLote.Remove(estadoLote);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Пример #2
0
        public ActionResult Delete(int id)
        {
            DBEstadoLote dbestado = new DBEstadoLote();
            EstadoLote   estado   = new EstadoLote(dbestado);

            estado.Delete(id);
            return(RedirectToAction("Index", "EstadoLote"));
        }
Пример #3
0
        public ActionResult Edit(EstadoLoteViewModels datos)
        {
            DBEstadoLote dbestado = new DBEstadoLote();
            EstadoLote   estado   = new EstadoLote(dbestado);

            estado.Update(datos);
            return(RedirectToAction("Index", "EstadoLote"));
        }
Пример #4
0
        public ActionResult  Edit(int id)
        {
            DBEstadoLote dbestado = new DBEstadoLote();
            EstadoLote   estado   = new EstadoLote(dbestado);
            var          datos    = estado.SelectForId(id);

            return(View(datos));
        }
Пример #5
0
        // GET: EstadoLote
        public ActionResult Index()
        {
            DBEstadoLote dbestado = new DBEstadoLote();
            EstadoLote   estado   = new EstadoLote(dbestado);
            var          lista    = estado.SelectAll();

            return(View(lista));
        }
 public ActionResult Edit([Bind(Include = "Codigo,Descripcion")] EstadoLote estadoLote)
 {
     if (ModelState.IsValid)
     {
         db.Entry(estadoLote).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(estadoLote));
 }
        public ActionResult Create([Bind(Include = "Codigo,Descripcion")] EstadoLote estadoLote)
        {
            if (ModelState.IsValid)
            {
                db.EstadoLote.Add(estadoLote);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(estadoLote));
        }
Пример #8
0
        public ActionResult Edit(EstadoLoteViewModels model)
        {
            if (ModelState.IsValid)
            {
                EstadoLote = dbCtx.EstadoLote.FirstOrDefault(a => a.Id == model.Id);
                EstadoLote.NombreEstado = model.NombreEstado;
                dbCtx.SaveChanges();
            }

            return(RedirectToAction("Index"));
        }
Пример #9
0
        public ActionResult Create(EstadoLoteViewModels datos)
        {
            ViewBag.Title = "Ingresar Estado";

            DBEstadoLote dbestado = new DBEstadoLote();
            EstadoLote   estado   = new EstadoLote(dbestado);

            estado.Save(datos);

            return(RedirectToAction("Index", "EstadoLote"));
        }
Пример #10
0
        public ActionResult Edit(int id)
        {
            ViewBag.Title = "Editar Estado";

            EstadoLoteViewModels estado = new EstadoLoteViewModels();

            EstadoLote          = dbCtx.EstadoLote.FirstOrDefault(a => a.Id == id);
            estado.Id           = EstadoLote.Id;
            estado.NombreEstado = EstadoLote.NombreEstado;

            return(View(estado));
        }
Пример #11
0
        // GET: EstadoLotes/Delete/5
        public ActionResult Delete(string id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            EstadoLote estadoLote = db.EstadoLote.Find(id);

            if (estadoLote == null)
            {
                return(HttpNotFound());
            }
            return(View(estadoLote));
        }
Пример #12
0
        public ActionResult Create()
        {
            ViewBag.Title = "Ingresar Lote";
            DBLotificadora dblotificadora = new DBLotificadora();
            Lotificadora   lotifi         = new Lotificadora(dblotificadora);
            DBManzana      dbmanzana      = new DBManzana();
            Manzana        manzana        = new Manzana(dbmanzana);
            DBEstadoLote   dbestado       = new DBEstadoLote();
            EstadoLote     estado         = new EstadoLote(dbestado);

            LoteIngresoViewModels lote = new LoteIngresoViewModels();

            lote.lotificadoras = lotifi.SelectAll();
            lote.manzanas      = manzana.SelectAll();
            lote.estados       = estado.SelectAll();

            return(View(lote));
        }
Пример #13
0
        public ActionResult Edit(int id)
        {
            DBLote         dblote         = new DBLote();
            Lote           lote           = new Lote(dblote);
            DBLotificadora dblotificadora = new DBLotificadora();
            Lotificadora   lotifi         = new Lotificadora(dblotificadora);
            DBManzana      dbmanzana      = new DBManzana();
            Manzana        manzana        = new Manzana(dbmanzana);
            DBEstadoLote   dbestado       = new DBEstadoLote();
            EstadoLote     estado         = new EstadoLote(dbestado);

            LoteIngresoViewModels lote2 = new LoteIngresoViewModels();

            lote2 = lote.SelectForId(id);
            lote2.lotificadoras = lotifi.SelectAll();
            lote2.manzanas      = manzana.SelectAll();
            lote2.estados       = estado.SelectAll();
            return(View(lote2));
        }
Пример #14
0
 public EstadoLoteController()
 {
     dbCtx      = new ApplicationDbContext();
     EstadoLote = new EstadoLote();
 }
Пример #15
0
        public ActionResult Create(LoteViewModels model)
        {
            var validImageTypes = new string[]
            {
                "image/gif",
                "image/jpeg",
                "image/pjpeg",
                "image/png",
            };

            if (model.ImageUpload == null || model.ImageUpload.ContentLength == 0)
            {
                ModelState.AddModelError("ImageUpload", "Es requerido.");
            }
            else if (!validImageTypes.Contains(model.ImageUpload.ContentType))
            {
                ModelState.AddModelError("ImageUpload", "Please choose either a GIF, JPG or PNG image.");
            }

            if (ModelState.IsValid)
            {
                Lotes.Precio   = model.Precio;
                Lotes.MedidaId = model.MedidaId;

                //Seleccionamos el estad cliente que sea 'ACTIVO' y luego lo agregamos a FK EstadoClienteId
                EstadoLote estado = dbCtx.EstadoLote.FirstOrDefault(e => e.NombreEstado == "Disponible");
                Lotes.EstadoLoteId = estado.Id;

                Lotes.LotificadoraId = model.LotificadoraId;
                Lotes.ManzanaId      = model.ManzanaId;
                Lotes.AreaId         = model.AreaId;
                Lotes.InteresId      = model.InteresId;

                if (model.ImageUpload != null && model.ImageUpload.ContentLength > 0)
                {
                    //Invertimos el nombre de la imagen y tomamos la extension de esta
                    string extension = Reverse(model.ImageUpload.FileName).Split('.')[0];
                    extension = Reverse(extension); //invertimos nuevamente la cadena generada en la linea anterior
                    string nameImage;

                    string time = DateTime.UtcNow.ToString();
                    time = time.Replace("/", "_");
                    time = time.Replace(" ", "_");
                    time = time.Replace(":", "_");
                    time = time.Replace(".", "");

                    //Le damos un nuevo nombre a la imagen, en base al fecha y hora para que no se repitan urls.
                    nameImage = time + "." + extension;

                    string uploadDir = "../Images/Lotes/";                                 //Ruta donde se guardara.
                    var    imagePath = Path.Combine(Server.MapPath(uploadDir), nameImage); //generamos el path

                    //generamos la url a guardar en la base de datos.
                    var imageUrl = Path.Combine(uploadDir, nameImage);
                    model.ImageUpload.SaveAs(imagePath); //guardamos la imagen.

                    Lotes.ImageUrl = imageUrl;           //por ultimo la pasamos la url al modelo para ser guardada en la BD.
                }

                dbCtx.Lote.Add(Lotes);
                dbCtx.SaveChanges();
            }

            return(RedirectToAction("Index"));
        }