public IEnumerable <Model.Model.Estoque> GetAll() { try { _estoque = new Data.Estoque.Estoque(); return(_estoque.GetAll()); } catch (Exception ex) { throw ex; } finally { _estoque = null; } }
public bool Alter(int id, Model.Model.Estoque item) { try { _estoque = new Data.Estoque.Estoque(); _estoque.Alter(id, item); return(true); } catch (Exception ex) { throw ex; } finally { _estoque = null; } }
public bool Save(Model.Model.Estoque item) { try { _estoque = new Data.Estoque.Estoque(); if (item.quantidadeEstoque == 0) { throw new Exception("QUANTIDADE DEVE SER MAIOR QUE 0"); } _estoque.Save(item); return(true); } catch (Exception ex) { throw ex; } finally{ _estoque = null; } }
public bool Save(Model.Model.Transacao item) { try { _transacao = new Data.Estoque.Transacao(); if (item.quantidade == 0) { throw new Exception("QUANTIDADE DEVE SER MAIOR QUE 0"); } IEnumerable <Model.Model.Estoque> estoque = new Data.Estoque.Estoque().Get(item.medicamento.id); if (estoque.FirstOrDefault() == null) { throw new Exception("NÃO FOI ENCONTRADO O MEDICAMENTO EM ESTOQUE."); } if (estoque.Count(c => c.idEstoque == item.estoque.idEstoque) == 0) { throw new Exception("ID DO ESTOQUE INVALIDO"); } if (item.eTipoTransacao == Model.Enum.eTransacao.eTipoTransacao.Saida) { item.quantidade = item.quantidade * -1; _transacao.Save(item); } else { throw new Exception("OPERAÇÃO NÃO IMPLEMENTADA"); } return(true); } catch (Exception ex) { throw ex; } finally { _transacao = null; } }