Example #1
0
        public IHttpActionResult PostHEBase(HEBase hEBase)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.HEBase.Add(hEBase);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateException)
            {
                if (HEBaseExists(hEBase.FuncionarioMatricula, hEBase.PercentualHoras, hEBase.CodMesOrcamento))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = hEBase.FuncionarioMatricula }, new HEBaseDTO(hEBase)));
        }
Example #2
0
 public HEBaseDTO(HEBase h)
 {
     if (h == null)
     {
         return;
     }
     FuncionarioMatricula = h.FuncionarioMatricula;
     CodMesOrcamento      = h.CodMesOrcamento;
     PercentualHoras      = h.PercentualHoras;
     QtdaHoras            = h.QtdaHoras;
 }
Example #3
0
        public IHttpActionResult DeleteHEBase(string matricula, int percentual, int mesOrcamento)
        {
            HEBase hEBase = db.HEBase.Find(matricula, percentual, mesOrcamento);

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

            HEBaseDTO h = new HEBaseDTO(hEBase);

            db.HEBase.Remove(hEBase);
            db.SaveChanges();

            return(Ok(h));
        }
Example #4
0
        public IHttpActionResult PutHEBase(string matricula, int percentual, int mesOrcamento, HEBase hEBase)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (matricula != hEBase.FuncionarioMatricula || percentual != hEBase.PercentualHoras || mesOrcamento != hEBase.CodMesOrcamento)
            {
                return(BadRequest());
            }

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

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!HEBaseExists(matricula, percentual, mesOrcamento))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public FuncionarioHEsDTO(Funcionario f, Ciclo c)
        {
            db = new Contexto();

            if (f == null || c == null)
            {
                return;
            }
            Matricula = f.Matricula;
            Nome      = f.Nome;
            Cargo     = f.Variaveis.Cargo.NomeCargo;

            HEs170 = new HashSet <QtdaHorasMesDTO>();
            HEs100 = new HashSet <QtdaHorasMesDTO>();
            HEs75  = new HashSet <QtdaHorasMesDTO>();
            HEs60  = new HashSet <QtdaHorasMesDTO>();
            HEs50  = new HashSet <QtdaHorasMesDTO>();
            int?qtda = 0;

            foreach (MesOrcamento m in c.MesesOrcamento.OrderBy(x => x.Mes))
            {
                HEBase he = db.HEBase.Find(f.Matricula, 170, m.Codigo);
                qtda = he == null ? 0 : he.QtdaHoras;
                ((HashSet <QtdaHorasMesDTO>)HEs170).Add(new QtdaHorasMesDTO
                {
                    CodMesOrcamento = m.Codigo,
                    Mes             = m.Mes,
                    QtdaHoras       = qtda.Value,
                    PercentualHoras = 170
                });

                he   = db.HEBase.Find(f.Matricula, 100, m.Codigo);
                qtda = he == null ? 0 : he.QtdaHoras;
                ((HashSet <QtdaHorasMesDTO>)HEs100).Add(new QtdaHorasMesDTO
                {
                    CodMesOrcamento = m.Codigo,
                    Mes             = m.Mes,
                    QtdaHoras       = qtda.Value,
                    PercentualHoras = 100
                });

                he   = db.HEBase.Find(f.Matricula, 75, m.Codigo);
                qtda = he == null ? 0 : he.QtdaHoras;
                ((HashSet <QtdaHorasMesDTO>)HEs75).Add(new QtdaHorasMesDTO
                {
                    CodMesOrcamento = m.Codigo,
                    Mes             = m.Mes,
                    QtdaHoras       = qtda.Value,
                    PercentualHoras = 75
                });

                he   = db.HEBase.Find(f.Matricula, 60, m.Codigo);
                qtda = he == null ? 0 : he.QtdaHoras;
                ((HashSet <QtdaHorasMesDTO>)HEs60).Add(new QtdaHorasMesDTO
                {
                    CodMesOrcamento = m.Codigo,
                    Mes             = m.Mes,
                    QtdaHoras       = qtda.Value,
                    PercentualHoras = 60
                });

                he   = db.HEBase.Find(f.Matricula, 50, m.Codigo);
                qtda = he == null ? 0 : he.QtdaHoras;
                ((HashSet <QtdaHorasMesDTO>)HEs50).Add(new QtdaHorasMesDTO
                {
                    CodMesOrcamento = m.Codigo,
                    Mes             = m.Mes,
                    QtdaHoras       = qtda.Value,
                    PercentualHoras = 50
                });
            }
        }