Exemplo n.º 1
0
        public async Task <ActionResult <detalle_ingreso> > Postdetalle_ingreso(detalle_ingreso detalle_Ingreso)
        {
            _context.detalle_ingresos.Add(detalle_Ingreso);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("Getdetalle_ingreso", new { id = detalle_Ingreso.id_detalle_ingreso }, detalle_Ingreso));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> PutDetalle_Ingreso(int id, detalle_ingreso detalle_Ingreso)
        {
            if (id != detalle_Ingreso.id_detalle_ingreso)
            {
                return(BadRequest());
            }

            //MI ENTIDAD YA TIENE LAS PROPIEDADDES O INFO QUE VOY A GUARDAR EN MY DB
            _context.Entry(detalle_Ingreso).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!detalle_ingresoExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }
            return(NoContent());
        }
        public async Task <IActionResult> PutDetalleIngreso(int id, detalle_ingreso detIngreso)
        {
            if (id != detIngreso.id_detalle_ingreso)
            {
                return(BadRequest());                                // si es diferente no da un badrequest
            }
            _context.Entry(detIngreso).State = EntityState.Modified; /*indicar al dbcontexr con el entity que lo que hay en detalle ingreso
                                                                      * vamos a realizar una modificacion , las entidad ya tiene las propiedades
                                                                      * o informacion que vamos a guardar*/

            /*el manejo de erro try nos evitará  tener problemas a evitar que si hay error que la api no falle*/
            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)//esto lo que hara un rollback a la operacion que se esta realizando
            {
                if (!DetalleIngresoExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }
            return(NoContent());
        }
        public ActionResult DeleteConfirmed(int id)
        {
            detalle_ingreso detalle_ingreso = db.detalle_ingreso.Find(id);

            db.detalle_ingreso.Remove(detalle_ingreso);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult Edit([Bind(Include = "iddetalle_ingreso,idingreso,idarticulo,cantidad,precio_compra,precio_venta")] detalle_ingreso detalle_ingreso)
 {
     if (ModelState.IsValid)
     {
         db.Entry(detalle_ingreso).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.idarticulo = new SelectList(db.articuloes, "idarticulo", "codigo", detalle_ingreso.idarticulo);
     ViewBag.idingreso  = new SelectList(db.ingresoes, "idingreso", "tipo_comprobante", detalle_ingreso.idingreso);
     return(View(detalle_ingreso));
 }
        // GET: /Detalle_Ingreso/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            detalle_ingreso detalle_ingreso = db.detalle_ingreso.Find(id);

            if (detalle_ingreso == null)
            {
                return(HttpNotFound());
            }
            return(View(detalle_ingreso));
        }
        // GET: /Detalle_Ingreso/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            detalle_ingreso detalle_ingreso = db.detalle_ingreso.Find(id);

            if (detalle_ingreso == null)
            {
                return(HttpNotFound());
            }
            ViewBag.idarticulo = new SelectList(db.articuloes, "idarticulo", "codigo", detalle_ingreso.idarticulo);
            ViewBag.idingreso  = new SelectList(db.ingresoes, "idingreso", "tipo_comprobante", detalle_ingreso.idingreso);
            return(View(detalle_ingreso));
        }