Ejemplo n.º 1
0
        public IHttpActionResult PutCochera(int id, Cochera cochera)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != cochera.CocheraId)
            {
                return(BadRequest());
            }

            db.Entry(cochera).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CocheraExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Ejemplo n.º 2
0
        public ActionResult Edit(Cochera cochera, HttpPostedFileBase fotoFile)
        {
            if (ModelState.IsValid)
            {
                db.Entry(cochera).State = EntityState.Modified;
                db.SaveChanges();

                if (fotoFile != null)
                {
                    var fotoAntigua = Request.MapPath("~/Uploads/Cocheras/" + cochera.Foto);
                    if (System.IO.File.Exists(fotoAntigua))
                    {
                        System.IO.File.Delete(fotoAntigua);
                    }

                    var timeStamp = DateTime.Now.ToString("yyyyMMddHHmmssffff");
                    cochera.Foto = timeStamp + ".png";
                    db.SaveChanges();
                    fotoFile?.SaveAs(Server.MapPath("~/Uploads/Cocheras/" + cochera.Foto));
                }

                return(RedirectToAction("Index"));
            }
            ViewBag.CocheraEstadoId = new SelectList(db.CocheraEstado, "CocheraEstadoId", "Descripcion", cochera.CocheraEstadoId);
            ViewBag.EmpresaId       = new SelectList(db.Empresa, "EmpresaId", "Nombre", cochera.EmpresaId);
            return(View(cochera));
        }
Ejemplo n.º 3
0
        public ActionResult DeleteConfirmed(int id)
        {
            Cochera cochera = db.Cochera.Find(id);

            db.Cochera.Remove(cochera);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 4
0
        public IHttpActionResult PostCochera(Cochera cochera)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.Cochera.Add(cochera);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = cochera.CocheraId }, cochera));
        }
Ejemplo n.º 5
0
        public IHttpActionResult GetCochera(int id)
        {
            db.Configuration.LazyLoadingEnabled = false;
            Cochera cochera = db.Cochera.Find(id);

            if (cochera == null)
            {
                return(NotFound());
            }

            return(Ok(cochera));
        }
Ejemplo n.º 6
0
 public ActionResult Edit([Bind(Include = "CocheraId,Nombre,Direccion,Descripcion,Longitud,Latitud,Foto,EmpresaId,CocheraEstadoId,CodigoPostal")] Cochera cochera)
 {
     if (ModelState.IsValid)
     {
         db.Entry(cochera).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.CocheraEstadoId = new SelectList(db.CocheraEstado, "CocheraEstadoId", "Descripcion", cochera.CocheraEstadoId);
     ViewBag.EmpresaId       = new SelectList(db.Empresa, "EmpresaId", "Nombre", cochera.EmpresaId);
     return(View(cochera));
 }
Ejemplo n.º 7
0
        public IHttpActionResult DeleteCochera(int id)
        {
            Cochera cochera = db.Cochera.Find(id);

            if (cochera == null)
            {
                return(NotFound());
            }

            db.Cochera.Remove(cochera);
            db.SaveChanges();

            return(Ok(cochera));
        }
Ejemplo n.º 8
0
        // GET: Manager/Cocheras/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Cochera cochera = db.Cochera.Find(id);

            if (cochera == null)
            {
                return(HttpNotFound());
            }
            return(View(cochera));
        }
Ejemplo n.º 9
0
        // GET: Manager/Cocheras/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Cochera cochera = db.Cochera.Find(id);

            if (cochera == null)
            {
                return(HttpNotFound());
            }
            ViewBag.CocheraEstadoId = new SelectList(db.CocheraEstado, "CocheraEstadoId", "Descripcion", cochera.CocheraEstadoId);
            ViewBag.EmpresaId       = new SelectList(db.Empresa, "EmpresaId", "Nombre", cochera.EmpresaId);
            return(View(cochera));
        }
Ejemplo n.º 10
0
        public ActionResult Create([Bind(Include = "CocheraId,Nombre,Direccion,Descripcion,Longitud,Latitud,EmpresaId,CocheraEstadoId,CodigoPostal")] Cochera cochera, HttpPostedFileBase fotoFile)
        {
            if (ModelState.IsValid)
            {
                db.Cochera.Add(cochera);
                db.SaveChanges();

                var timeStamp = DateTime.Now.ToString("yyyyMMddHHmmssffff");

                cochera.Foto = timeStamp + ".png";
                db.SaveChanges();
                fotoFile?.SaveAs(Server.MapPath("~/Uploads/Cocheras/" + cochera.Foto));

                return(RedirectToAction("Index"));
            }

            ViewBag.CocheraEstadoId = new SelectList(db.CocheraEstado, "CocheraEstadoId", "Descripcion", cochera.CocheraEstadoId);
            ViewBag.EmpresaId       = new SelectList(db.Empresa, "EmpresaId", "Nombre", cochera.EmpresaId);
            return(View(cochera));
        }
Ejemplo n.º 11
0
        public int AltaCochera(Cochera objCochera) // ref y int idcliente, int idplan, int idvehiculo
        {
            try
            {
                conn.Open();
                string query = @" Insert into Cochera (NumeroCochera)
                                    values ('" + objCochera.NumeroCochera + "')";

                SqlCommand command = new SqlCommand(query, conn);

                resultado = command.ExecuteNonQuery();
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                conn.Close();
            }

            return(resultado);
        }
Ejemplo n.º 12
0
 public int AltaCochera(Cochera objCochera) //int idcliente, int idplan, int idvehiculo
 {
     return(objDC.AltaCochera(objCochera)); //ref - idcliente, idplan, idvehiculo
 }