Exemple #1
0
        public async Task <IHttpActionResult> PutRendimento(int id, Rendimento rendimento)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
Exemple #2
0
        public async Task <IHttpActionResult> GetRendimento(int id)
        {
            Rendimento rendimento = await db.Rendimentos.FindAsync(id);

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

            return(Ok(rendimento));
        }
Exemple #3
0
        public async Task <IHttpActionResult> PostRendimento(Rendimento rendimento)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.Rendimentos.Add(rendimento);
            await db.SaveChangesAsync();

            return(CreatedAtRoute("DefaultApi", new { id = rendimento.RendimentoId }, rendimento));
        }
Exemple #4
0
        public async Task <IHttpActionResult> DeleteRendimento(int id)
        {
            Rendimento rendimento = await db.Rendimentos.FindAsync(id);

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

            db.Rendimentos.Remove(rendimento);
            await db.SaveChangesAsync();

            return(Ok(rendimento));
        }
 public bool IsRendimentoTaxavel(Rendimento rendimento)
 {
     return(RENDIMENTOS_TAXAVEIS.Contains(rendimento.Tipo));
 }