public int Post(Coperativa obj)
        {
            using (var ct = new Contexto())
            {
                ct.DbCoperativa.Add(obj);

                return ct.SaveChanges();
            }
        }
        public void Delete(int id)
        {
            using (var ct = new Contexto())
            {
                var coper = ct.DbCoperativa.FirstOrDefault(x => x.Id == id);

                if (coper == null)
                    return;

                coper.Ativo = false;
                coper.Excluido = true;

                ct.Entry(coper).State = EntityState.Modified;

                ct.SaveChanges();
            }
        }
        public void Put(Coperativa obj)
        {
            using (var ct = new Contexto())
            using (var trans = ct.Database.BeginTransaction())
            {
                try
                {
                    new ControleMensalRepository().Put(obj.Controles.First(), ct);

                    if (obj.Telefones.Any())
                        new TelefoneRepository().Put(obj.Telefones, obj.Id, ct);

                    obj.Controles = null;
                    obj.Telefones = null;

                    ct.DbCoperativa.AddOrUpdate(obj);
                    var a = ct.SaveChanges();
                    trans.Commit();
                }
                catch (Exception ex)
                {
                    trans.Rollback();
                    throw ex;
                }
            }
        }