Exemplo n.º 1
0
        public IHttpActionResult post(Delito delito)
        {
            if (delito == null)
            {
                return(NotFound());
            }                                         //404 notfound
            largoString = Int32.Parse(delito.Nombre.Length.ToString());
            if (delito.Nombre == null || largoString < 2)
            {
                return(Ok(new { Estado = "ERROR", Mensaje = "Debe ingresar un nombre valido." }));
            }
            if (delito.CondenaMinima <= 0)
            {
                return(Ok(new { Estado = "ERROR", Mensaje = "Debe ingresar una condena Minima." }));
            }
            if (delito.CondenaMaxima <= 0)
            {
                return(Ok(new { Estado = "ERROR", Mensaje = "Debe ingresar una condena Maxima." }));
            }
            context.Delitos.Add(delito);
            int filasAfectadas = context.SaveChanges();

            if (filasAfectadas == 0)
            {
                return(InternalServerError());
            }
            return(Ok(new { Estado = "ERROR", Mensaje = "Agregado Correctamente" }));
        }
Exemplo n.º 2
0
        public IHttpActionResult put(Delito delito)
        {
            context.Entry(delito).State = System.Data.Entity.EntityState.Modified;

            if (context.SaveChanges() > 0)
            {
                return(Ok(new { Estado = "SUCCESS", Mensaje = "Modificado correctamente" }));
            }

            return(InternalServerError());
        }