Exemple #1
0
        public async Task <IHttpActionResult> Postretiro(retiro retiro)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.retiro.Add(retiro);

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (retiroExists(retiro.id))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = retiro.id }, retiro));
        }
Exemple #2
0
        public async Task <IHttpActionResult> Putretiro(int id, retiro retiro)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

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

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!retiroExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Exemple #3
0
        public async Task <IHttpActionResult> Getretiro(int id)
        {
            retiro retiro = await db.retiro.FindAsync(id);

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

            return(Ok(retiro));
        }
Exemple #4
0
        public async Task <IHttpActionResult> Deleteretiro(int id)
        {
            retiro retiro = await db.retiro.FindAsync(id);

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

            db.retiro.Remove(retiro);
            await db.SaveChangesAsync();

            return(Ok(retiro));
        }
Exemple #5
0
        public ActionResult Enviar_Retiro()
        {
            int valor = Convert.ToInt32(Request.Form["cantidad"]);

            if (valor % 100 == 0)
            {
                retiro r = new retiro();
                r.monto = Convert.ToDecimal(valor);
                r.fecha = System.DateTime.Now;

                db.retiro.Add(r);
                db.SaveChanges();

                List <int> billetes = desglosar_retiro(valor);
                int        cont500 = 0, cont200 = 0, cont100 = 0;

                foreach (int i in billetes)
                {
                    if (i == 500)
                    {
                        cont500++;
                    }
                    if (i == 200)
                    {
                        cont200++;
                    }
                    if (i == 100)
                    {
                        cont100++;
                    }
                }


                ViewData["exito"] = "exito";
                ViewData["500"]   = cont500;
                ViewData["200"]   = cont200;
                ViewData["100"]   = cont100;
                return(View("Index"));
            }
            else
            {
                ViewData["fracaso"] = "fracaso";
                return(View("Index"));
            }
        }