public ActionResult Edit(int id, Alquiler alquiler)
        {
            //var miPropietario = repositorio.ObtenerPorId(id);

            if (id != alquiler.AlquilerId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    repositorio.Modificacion(alquiler);
                }
                catch (Exception ex)
                {
                    ViewBag.Error      = ex.Message;
                    ViewBag.StackTrate = ex.StackTrace;
                    return(View());
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View());
        }
 public ActionResult Create(Alquiler alquiler)
 {
     try
     {
         return(View());
     }
     catch (Exception ex)
     {
         ViewBag.Error      = ex.Message;
         ViewBag.StackTrate = ex.StackTrace;
         return(View());
     }
 }
        public int Alta(Alquiler entidad)
        {
            int res = -1;

            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                string sql = $"INSERT INTO Alquileres ( Descripcion,FechaAlta , FechaBaja , Monto , InmuebleId , InquilinoId) " +
                             $"VALUES ('{entidad.Descripcion}','{entidad.FechaAlta}', '{entidad.FechaBaja}','{entidad.Monto}','{entidad.InmuebleId}','{entidad.InquilinoId}')";
                using (SqlCommand command = new SqlCommand(sql, connection))
                {
                    command.CommandType = CommandType.Text;
                    connection.Open();
                    res = command.ExecuteNonQuery();
                    command.CommandText = "SELECT SCOPE_IDENTITY()";
                    var id = command.ExecuteScalar();
                    entidad.AlquilerId = Convert.ToInt32(id);
                    connection.Close();
                }
            }
            return(res);
        }