public IHttpActionResult Putcalculos(int id, calculos calculos)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != calculos.id_calculo)
            {
                return(BadRequest());
            }

            db.Entry(calculos).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!calculosExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public ActionResult Create([Bind(Include = "id_calculo,id_donador_calculos,id_gasto_calculos,id_gasto1_calculos,id_gasto2_calculos,fecha,total")] calculos calculos)
        {
            if (ModelState.IsValid)
            {
                //if (calculos. == 1)
                //{
                //    donadores.total = ((donadores.aporte_pib * 5) / 100);
                //}
                //else
                //{
                //    donadores.total = ((donadores.aporte_pib * 10) / 100);
                //}
                calculos.total = 10000;
                calculos.fecha = DateTime.Now;
                db.calculos.Add(calculos);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.id_donador_calculos = new SelectList(db.donadores, "id_donador", "nombre", calculos.id_donador_calculos);
            ViewBag.id_gasto_calculos   = new SelectList(db.gasto, "id_gasto", "nombre", calculos.id_gasto_calculos);
            ViewBag.id_gasto1_calculos  = new SelectList(db.gasto1, "id_gasto1", "nombre", calculos.id_gasto1_calculos);
            ViewBag.id_gasto2_calculos  = new SelectList(db.gasto2, "id_gasto2", "nombre", calculos.id_gasto2_calculos);
            return(View(calculos));
        }
Пример #3
0
        static void Main(string[] args)
        {
            var calcular = new calculos();

            Console.WriteLine(calcular.CalculoAdicao(5, 5));

            Console.ReadKey();
        }
        public ActionResult DeleteConfirmed(int id)
        {
            calculos calculos = db.calculos.Find(id);

            db.calculos.Remove(calculos);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        public IHttpActionResult Getcalculos(int id)
        {
            calculos calculos = db.calculos.Find(id);

            if (calculos == null)
            {
                return(NotFound());
            }

            return(Ok(calculos));
        }
        public IHttpActionResult Postcalculos(calculos calculos)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.calculos.Add(calculos);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = calculos.id_calculo }, calculos));
        }
        // GET: calculosMVC/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            calculos calculos = db.calculos.Find(id);

            if (calculos == null)
            {
                return(HttpNotFound());
            }
            return(View(calculos));
        }
 public ActionResult Edit([Bind(Include = "id_calculo,id_donador_calculos,id_gasto_calculos,id_gasto1_calculos,id_gasto2_calculos,fecha,total")] calculos calculos)
 {
     if (ModelState.IsValid)
     {
         db.Entry(calculos).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.id_donador_calculos = new SelectList(db.donadores, "id_donador", "nombre", calculos.id_donador_calculos);
     ViewBag.id_gasto_calculos   = new SelectList(db.gasto, "id_gasto", "nombre", calculos.id_gasto_calculos);
     ViewBag.id_gasto1_calculos  = new SelectList(db.gasto1, "id_gasto1", "nombre", calculos.id_gasto1_calculos);
     ViewBag.id_gasto2_calculos  = new SelectList(db.gasto2, "id_gasto2", "nombre", calculos.id_gasto2_calculos);
     return(View(calculos));
 }
        public IHttpActionResult Deletecalculos(int id)
        {
            calculos calculos = db.calculos.Find(id);

            if (calculos == null)
            {
                return(NotFound());
            }

            db.calculos.Remove(calculos);
            db.SaveChanges();

            return(Ok(calculos));
        }
        // GET: calculosMVC/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            calculos calculos = db.calculos.Find(id);

            if (calculos == null)
            {
                return(HttpNotFound());
            }
            ViewBag.id_donador_calculos = new SelectList(db.donadores, "id_donador", "nombre", calculos.id_donador_calculos);
            ViewBag.id_gasto_calculos   = new SelectList(db.gasto, "id_gasto", "nombre", calculos.id_gasto_calculos);
            ViewBag.id_gasto1_calculos  = new SelectList(db.gasto1, "id_gasto1", "nombre", calculos.id_gasto1_calculos);
            ViewBag.id_gasto2_calculos  = new SelectList(db.gasto2, "id_gasto2", "nombre", calculos.id_gasto2_calculos);
            return(View(calculos));
        }