예제 #1
0
 public async System.Threading.Tasks.Task <bool> GuardarVendedor(VendedoresModel modelo)
 {
     try
     {
         System.Threading.Tasks.Task <bool> resultado = new AccesoDatos.CiudadVendedor().GuardarVendedorAsing(modelo);
         return(await resultado);
     }
     catch (Exception ex)
     {
         throw (ex);
     }
 }
예제 #2
0
        public ActionResult _AgregarVendedor(int?id, int ciudad)
        {
            Datos.Modelos.VendedoresModel modelo = new VendedoresModel();

            if (id != null)
            {
                modelo = obtenerunVendedor((int)id);
                modelo.listaCiudades   = new SelectList(modelo.combociudades, "Id", "Nombre", modelo.Ciudad.CiudadId);
                modelo.ciudadantiguaid = ciudad;
            }
            else
            {
                modelo.CiudadId        = ciudad;
                modelo.ciudadantiguaid = ciudad;
            }

            return(PartialView("~/Views/CiudadVendedores/AgregarVendedor.cshtml", modelo));
        }
예제 #3
0
        public async Task <bool> GuardarVendedorAsing(VendedoresModel modelo)
        {
            bool   respuesta = false;
            Ciudad ciudades  = new Ciudad();

            try
            {
                using (ContextoDatos db = new ContextoDatos())
                {
                    Vendedor vendedor = new Vendedor
                    {
                        Apellido = modelo.Apellido,
                        Numero_Identificacion = modelo.Numero_Identificacion,
                        VendedorId            = modelo.VendedorId,
                        CiudadId = modelo.CiudadId,
                        Codigo   = modelo.Codigo,
                        Nombre   = modelo.Nombre,
                    };
                    if (vendedor.VendedorId > 0)
                    {
                        db.Entry(vendedor).State = EntityState.Modified;
                    }
                    else
                    {
                        db.Entry(vendedor).State = EntityState.Added;
                    }
                    db.SaveChanges();
                    respuesta = true;
                }
            }
            catch (Exception ex)
            {
                throw (ex);
            }
            return(respuesta);
        }