public async Task <IActionResult> Post(Programador programador) { _context.Add(programador); await _context.SaveChangesAsync(); return(Ok(programador.Id)); }
public async Task <LibroDTO> ActualizarLibro(int LibroId, LibroDTO libroDTO) { try { if (LibroId == libroDTO.Id) { Libro libroDetalles = await _db.Libro.FindAsync(LibroId); Libro libro = _mapper.Map <LibroDTO, Libro>(libroDTO, libroDetalles); libro.Autor = ""; libro.FechaActualizacion = DateTime.Now; var updateLibro = _db.Libro.Update(libro); await _db.SaveChangesAsync(); return(_mapper.Map <Libro, LibroDTO>(updateLibro.Entity)); } else { return(null); } } catch (Exception) { return(null); } }
public async Task <IActionResult> Create([Bind("id,patente,km,anioFab,modelo,precio,ClienteId")] Auto auto) { if (ModelState.IsValid) { _context.Add(auto); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(auto)); }
public async Task <IActionResult> Create([Bind("id,nombre,apellido,dni")] Cliente cliente) { if (ModelState.IsValid) { _context.Add(cliente); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(cliente)); }
public async Task <ActionResult <SexoDTO> > PostSexo(SexoDTO sexoDTO) { var sexo = new Sexo { Nombre = sexoDTO.Nombre }; _context.Sexos.Add(sexo); await _context.SaveChangesAsync(); return(CreatedAtAction(nameof(GetSexos), new { id = sexo.Id }, SexoToDTO(sexo))); }
public async Task <IActionResult> Create([Bind("idFactura,tipoFactura,importe,ClienteId")] Factura factura) { if (factura.importe < 0) { return(ViewBag.ShowAlert); } if (ModelState.IsValid) { _context.Add(factura); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(factura)); }
public async Task <ActionResult <TipoIdentificacionDTO> > PostTipoIdentificacion( TipoIdentificacionDTO tipoIdentificacionDTO) { var tipoIdentificacion = new TipoIdentificacion { Nombre = tipoIdentificacionDTO.Nombre }; _context.TipoIdentificacions.Add(tipoIdentificacion); await _context.SaveChangesAsync(); return(CreatedAtAction(nameof(GetTiposIdentificacion), new { id = tipoIdentificacion.Id }, TipoIdentificacionToDTO(tipoIdentificacion))); }
public async Task <MovimientoDto> GuardarMovimiento(MovimientoDto movimiento) { Movimientos movimientoGuardar = new Movimientos { Id = movimiento.Id, BodegaId = movimiento.Bodega.Id, ProductoId = movimiento.Producto.Id, FechaMovimiento = movimiento.FechaMovimiento, Cantidad = movimiento.Cantidad, Tipo = movimiento.Tipo, Valor = movimiento.Valor }; _contexto.Movimientos.Add(movimientoGuardar); await _contexto.SaveChangesAsync(); Movimientos movimientoCreado = await _contexto.Movimientos.FirstOrDefaultAsync(f => f.Id == movimiento.Id); return(MovimientoMapeo.Convertir(movimientoCreado)); }
public async Task <ActionResult <PersonaDTO> > PostPersona(PersonaDTO personaDTO) { var persona = new Persona { Identificacion = personaDTO.Identificacion, Nombres = personaDTO.Nombres, Apellidos = personaDTO.Apellidos, Direccion = personaDTO.Direccion, Telefono = personaDTO.Telefono, SexoId = personaDTO.SexoNombre, TipoIdentififcacionId = personaDTO.TipoIdentificacionNombre }; _context.Personas.Add(persona); await _context.SaveChangesAsync(); return(CreatedAtAction(nameof(GetPersonas), new { id = persona.Id }, PersonaToDTO(persona))); }
public static async Task InsertDatosEjemplo(AplicacionDbContext context) { if (!context.Bodegas.Any()) { List <Bodega> bodegasDefault = new List <Bodega> { new Bodega { Id = Guid.Parse("40e05749-8b35-42c3-b68e-1232da850baf"), Nombre = "Bodega 1", Descripcion = "Bodega de prueba 1", Ubicacion = "Ubicacion 1", CapacidadMaxima = 100 }, new Bodega { Id = Guid.Parse("03d734ad-4bd8-444f-b9dd-d497d1fa3974"), Nombre = "Bodega 2", Descripcion = "Bodega de prueba 2", Ubicacion = "Ubicacion 1", CapacidadMaxima = 150 }, new Bodega { Id = Guid.Parse("460f54b0-0555-4ae5-a119-47cffd8b5d33"), Nombre = "Bodega 3", Descripcion = "Bodega de prueba 3", Ubicacion = "Ubicacion 2", CapacidadMaxima = 200 } }; context.Bodegas.AddRange(bodegasDefault); } if (!context.Productos.Any()) { List <Producto> productosDefault = new List <Producto> { new Producto { Id = Guid.Parse("d73b1452-fc54-4920-a796-a10f25b48715"), Nombre = "Producto de prueba 1", Descripcion = "Esto es un producto de prueba 1", sku = "PRO-PRU-1" }, new Producto { Id = Guid.Parse("9ae171ea-c81a-454c-8dd8-c5d0ca433f5c"), Nombre = "Producto de prueba 2", Descripcion = "Esto es un producto de prueba 2", sku = "PRO-PRU-2" }, new Producto { Id = Guid.Parse("81eafc34-4146-468b-b830-30010ed840f6"), Nombre = "Producto de prueba 3", Descripcion = "Esto es un producto de prueba 3", sku = "PRO-PRU-3" } }; context.Productos.AddRange(productosDefault); } await context.SaveChangesAsync(); }
public async Task <IActionResult> Update(int id, Integrantes integrantes, Direccion direccion, DocumentoIdentificacion documento, DatosFamiliares familiares, DatosAcademicos academicos, DatosEclesiasticos eclesiasticos, DatosLaborales laborales, ImagesModel imgModel) { if (id != integrantes.IntegranteId) { return(NotFound()); } //Adjuntar Documento string stringFileNameDoc = UploadFileDoc(imgModel); var ss = new DocumentoIdentificacion { NombreDocumento = stringFileNameDoc }; documento.NombreDocumento = stringFileNameDoc; foreach (var direc in bd.Direccion) { integrantes.DireccionId = direc.DireccionId; } foreach (var fam in bd.DatosFamiliares) { integrantes.DatosFamiliaresId = fam.DatosFamiliaresId; } foreach (var aca in bd.DatosAcademicos) { integrantes.DatosAcademicosId = aca.DatosAcademicosId; } foreach (var ecle in bd.DatosEclesiasticos) { integrantes.DatosEclesiasticosId = ecle.DatosEclesiasticosId; } foreach (var doc in bd.DocumentoIdentificacion) { integrantes.DocIdentidadId = doc.DocIdentidadId; } foreach (var lab in bd.DatosLaborales) { integrantes.DatosLaboralesId = lab.DatosLaboralesId; } bd.DatosFamiliares.Update(familiares); bd.Direccion.Update(direccion); await bd.SaveChangesAsync(); bd.DocumentoIdentificacion.Update(documento); await bd.SaveChangesAsync(); bd.DatosLaborales.Update(laborales); await bd.SaveChangesAsync(); bd.DatosEclesiasticos.Update(eclesiasticos); await bd.SaveChangesAsync(); bd.DatosAcademicos.Update(academicos); await bd.SaveChangesAsync(); bd.Integrantes.Update(integrantes); await bd.SaveChangesAsync(); return(RedirectToAction("Index")); }