コード例 #1
0
        public ActionResult Excluir(int id)
        {
            using (var session = NHibernateHelper.OpenSession())
            {
                using (var transaction = session.BeginTransaction())
                {
                    IList <Categoria> CatList = session.Query <Categoria>().ToList();

                    var listaCategorias = (from u in CatList.AsEnumerable()
                                           select new SelectListItem
                    {
                        Text = u.descricao,
                        Value = u.categoriaId.ToString(),
                    }).AsEnumerable();
                    ViewBag.ListaDrop = listaCategorias;
                    var subCategorias = session.Get <SubCategoria>(id);
                    SubCategoriaModel subCategoriasDetalhes = new SubCategoriaModel();
                    subCategoriasDetalhes.subCategoriaId = subCategorias.subCategoriaId;
                    subCategoriasDetalhes.descricao      = subCategorias.descricao;
                    subCategoriasDetalhes.slug           = subCategorias.slug;
                    subCategoriasDetalhes.categoria      = new CategoriaModel {
                        categoriaId = subCategorias.categoria.categoriaId, descricao = subCategorias.categoria.descricao, slug = subCategorias.categoria.slug
                    };

                    return(View(subCategoriasDetalhes));
                }
            }
        }
コード例 #2
0
 public void Grabar(SubCategoriaModel datos)
 {
     using (var c = new Contexto())
     {
         c.SubCategoria.Add(datos);
         c.SaveChanges();
     }
 }
コード例 #3
0
 public ActionResult Edit([Bind(Include = "Id,Nombre,CategoriaId, FijaMensualmente, Tipo, Monto")] SubCategoriaModel subCategoriaModel)
 {
     if (ModelState.IsValid)
     {
         db.Actualizar(subCategoriaModel, CategoriaId);
         return(RedirectToAction("Index"));
     }
     ViewBag.CategoriaId = new SelectList(dc.Listar(), "Id", "Nombre", subCategoriaModel.CategoriaId);
     return(View(subCategoriaModel));
 }
コード例 #4
0
        // GET: SubCategoria/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            SubCategoriaModel subCategoriaModel = db.Devolver(id);

            if (subCategoriaModel == null)
            {
                return(HttpNotFound());
            }
            return(View(subCategoriaModel));
        }
コード例 #5
0
        // GET: SubCategoria/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            SubCategoriaModel subCategoriaModel = db.Devolver(id);

            if (subCategoriaModel == null)
            {
                return(HttpNotFound());
            }
            ViewBag.CategoriaId = new SelectList(dc.Listar(), "Id", "Nombre", subCategoriaModel.CategoriaId);
            CategoriaId         = subCategoriaModel.CategoriaId;
            return(View(subCategoriaModel));
        }
コード例 #6
0
 public void Actualizar(SubCategoriaModel datos, int idCategoriaViejo)
 {
     using (var c = new Contexto())
     {
         if (datos.CategoriaId != idCategoriaViejo)
         {
             //Modifico los movimientos idCategoria
             List <MovimientosModel> mov = c.Movimiento.Where(f => f.SubCategoriaId == datos.Id).ToList();
             foreach (MovimientosModel m in mov)
             {
                 m.CategoriaId = datos.CategoriaId;
             }
         }
         c.Entry(datos).State = EntityState.Modified;
         c.SaveChanges();
     }
 }
コード例 #7
0
        public ActionResult Detalhes(int id)
        {
            using (var session = NHibernateHelper.OpenSession())
            {
                using (var transaction = session.BeginTransaction())
                {
                    var subCategorias = session.Get <SubCategoria>(id);
                    SubCategoriaModel subCategoriasDetalhes = new SubCategoriaModel();
                    subCategoriasDetalhes.subCategoriaId = subCategorias.subCategoriaId;
                    subCategoriasDetalhes.descricao      = subCategorias.descricao;
                    subCategoriasDetalhes.slug           = subCategorias.slug;
                    subCategoriasDetalhes.categoria      = new CategoriaModel {
                        categoriaId = subCategorias.categoria.categoriaId, descricao = subCategorias.categoria.descricao, slug = subCategorias.categoria.slug
                    };

                    return(View(subCategoriasDetalhes));
                }
            }
        }
コード例 #8
0
ファイル: Figura.cs プロジェクト: JoseQuiros/ExamenLenguajes
        public IActionResult RegistrarSubCategoria(SubCategoriaModel productoModel)
        {
            string         connectionString = Configuration["ConnectionStrings:DB_Connection"];
            CategoriaModel productoTemp     = new CategoriaModel();

            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                string sqlQuery = $"exec insertSubCategoria @idCategoria='{productoModel.Id}', @nombre='{productoModel.Nombre}', @id='{productoModel.idSubCategoria}'";

                using (SqlCommand command = new SqlCommand(sqlQuery, connection))
                {
                    command.CommandType = CommandType.Text;
                    connection.Open();
                    command.ExecuteReader();
                    connection.Close();
                }
            } // ModelState.IsValid


            return(View());
        } // Registrar