Beispiel #1
0
        public OutPutUpdateFrente UpdateFrente(InputUpdateFrente item)
        {
            var retorno = new OutPutUpdateFrente();

            var frente = new bFrente(db).BuscaFrenteId(item.IdFrente);

            frente.NmFrente      = item.NmFrente;
            frente.CdFrente      = Convert.ToInt32(item.CdFrenteTexto);
            frente.CdFrenteTexto = item.CdFrenteTexto;
            while (frente.CdFrenteTexto.Length < 2)
            {
                frente.CdFrenteTexto = "0" + item.CdFrenteTexto;
            }

            db.SaveChanges();

            foreach (var coord in item.Coordenadores)
            {
                var inputAddFrenteCoordenador = new InputAddFrenteCoordenador();
                inputAddFrenteCoordenador.IdFrente = frente.IdFrente;
                inputAddFrenteCoordenador.IdPessoa = coord.IdPessoa;

                new bFrenteCoordenador(db).AddFrenteCoordenador(inputAddFrenteCoordenador);
            }

            new bFrenteCoordenador(db).RemoveFrenteCoordenadoresExcluidos(item.Coordenadores, item.IdFrente);

            retorno.Result = true;

            return(retorno);
        }
        private int ObterFrentePadrao(int idContrato_)
        {
            var frente = new bFrente(db).BuscaFrenteIdContrato(idContrato_)?.FirstOrDefault();

            return(frente == null ? 0 : frente.IdFrente);
        }