示例#1
0
        public async Task <IHttpActionResult> Putcuadre(int id, cuadre cuadre)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

            db.Entry(cuadre).State = System.Data.Entity.EntityState.Modified;

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
示例#2
0
        public async Task <IHttpActionResult> Getcuadre(int id)
        {
            cuadre cuadre = await db.cuadre.FindAsync(id);

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

            return(Ok(cuadreDto.FromModel(cuadre)));
        }
示例#3
0
        public async Task <IHttpActionResult> Deletecuadre(int id)
        {
            cuadre cuadre = await db.cuadre.FindAsync(id);

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

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

            return(Ok(cuadre));
        }
示例#4
0
 public static cuadreDto FromModel(cuadre model)
 {
     return(new cuadreDto()
     {
         id = model.id,
         fecha = model.fecha,
         cajero = model.cajero,
         local = model.local,
         estado = model.estado,
         usuarionombre = model.usuario.nombre,
         localnombre = model.local1.nombre,
         usuario = usuarioDto.FromModel(model.usuario),
     });
 }
示例#5
0
        public async Task <IHttpActionResult> Postcuadre(cuadre cuadre)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (cuadreExists(cuadre.fecha, cuadre.local))
            {
                return(Content(HttpStatusCode.Conflict, new { mensaje = "Ya existe un registro de cierre con fecha posterior a la indicada, verifique." }));
            }

            if (cuadreExists(cuadre.local, cuadre.estado))
            {
                return(Content(HttpStatusCode.Conflict, new { mensaje = "Existe un registro de cierre aun no consolidado, verifique." }));
            }

            db.cuadre.Add(cuadre);
            await db.SaveChangesAsync();

            return(CreatedAtRoute("DefaultApi", new { id = cuadre.id }, cuadre));
        }