public int InsertDatas(Datas datas) { try { InstanciarKeyGenBO(); int retorno = 0; if (_keyGenBo.VerificaSeExisteDatas(datas) == null) { InstanciarBanco(); _banco.Entry(datas).State = EntityState.Added; retorno = _banco.SaveChanges(); } return retorno; } catch (CustomException erro) { throw new CustomException(erro.Message); } catch (Exception erro) { throw new Exception(erro.Message); } }
public Datas VerificaSeExisteDatas(Datas data) { try { return _banco.Datas.FirstOrDefault(c => c.Data == data.Data); } catch (CustomException erro) { throw new CustomException(erro.Message); } catch (Exception erro) { throw new Exception(erro.Message); } }