public string Add(CentroCusto centroCusto) { var centroCustoRules = new CentroCustoRules(); if (!centroCustoRules.Add(centroCusto)) { return Error(centroCustoRules.MessageError); } return Success(centroCusto); }
public bool Excluir(CentroCusto centroCusto) { var centroCustoRepositorio = new CentroCustoRepositorio(); if (centroCustoRepositorio.HashVinculo(centroCusto)) { this.MessageError = "CENTRO_CUSTO_VINCULADO"; return false; } centroCustoRepositorio.Delete(centroCusto); return true; }
public void Update(CentroCusto centroCusto) { var oldNome = this.Db.ExecuteScalar<string>("SELECT Nome FROM CentroCusto WHERE Id = @0", centroCusto.Id); var newNome = centroCusto.Nome; var centros = this.Db.Fetch<CentroCusto>("SELECT * FROM CentroCusto WHERE Nome LIKE @0", oldNome + ":%").ToList(); foreach (var centro in centros) { centro.Nome = centro.Nome.Replace(oldNome, newNome); this.Db.Update(centro); } this.Db.Update(centroCusto); }
public bool Update(CentroCusto centroCusto) { if (!Account.Current.Permissao.Has("UPDATE_CENTRO_CUSTO")) { this.MessageError = "USUARIO_SEM_PERMISSAO"; return false; } var centroCustoRepositorio = new CentroCustoRepositorio(); if (centroCustoRepositorio.Has(centroCusto)) { this.MessageError = "CENTRO_CUSTO_EXISTENTE"; return false; } centroCustoRepositorio.Update(centroCusto); return true; }
public bool Has(CentroCusto centroCusto) { return this.Db.ExecuteScalar<bool>("SELECT COUNT(*) FROM CentroCusto WHERE Nome = @0 AND Id != @1", centroCusto.Nome, centroCusto.Id); }
public void Add(CentroCusto centroCusto) { this.Db.Insert(centroCusto); }
public bool HashVinculo(CentroCusto centroCusto) { return this.Db.ExecuteScalar<bool>("SELECT COUNT(*) FROM FinanceiroItem WHERE FinanceiroItem.CentroCustoId = @0", centroCusto.Id); }
public void Delete(CentroCusto centroCusto) { this.Db.Execute("DELETE FROM CentroCusto WHERE CentroCusto.Id = @0", centroCusto.Id); }