Example #1
0
        public IHttpActionResult PostFeriasPorCR(FeriasPorCR feriasPorCR)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.FeriasPorCR.Add(feriasPorCR);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateException)
            {
                if (FeriasPorCRExists(feriasPorCR.CodigoCR, feriasPorCR.CodMesOrcamento))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = feriasPorCR.CodigoCR }, new FeriasPorCRDTO(feriasPorCR)));
        }
Example #2
0
        public IHttpActionResult PutFeriasPorCR(string cr, int mes, FeriasPorCR feriasPorCR)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (cr != feriasPorCR.CodigoCR || mes != feriasPorCR.CodMesOrcamento)
            {
                return(BadRequest());
            }

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

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!FeriasPorCRExists(cr, mes))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
 public FeriasPorCRDTO(FeriasPorCR f)
 {
     if (f == null)
     {
         return;
     }
     CodigoCR        = f.CodigoCR;
     CodMesOrcamento = f.CodMesOrcamento;
     Percentual      = f.Percentual;
 }
Example #4
0
        public IHttpActionResult GetFeriasPorCR(string cr, int mes)
        {
            FeriasPorCR feriasPorCR = db.FeriasPorCR.Find(cr, mes);

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

            return(Ok(new FeriasPorCRDTO(feriasPorCR)));
        }
Example #5
0
        public IHttpActionResult DeleteFeriasPorCR(string cr, int mes)
        {
            FeriasPorCR feriasPorCR = db.FeriasPorCR.Find(cr, mes);

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

            FeriasPorCRDTO f = new FeriasPorCRDTO(feriasPorCR);

            db.FeriasPorCR.Remove(feriasPorCR);
            db.SaveChanges();

            return(Ok(f));
        }