@Override public Long receive(Long id, int amount, double price) { Notebook notebook = menu.getNotebookDao().read(id); Store store = new Store(notebook, amount, price); Long id2 = storeDao.create(store); return id2; }
@Override public boolean removeFromStore(Store store, int amount) { Integer newQuant = store.getQuantity() - amount; store.setQuantity(newQuant); return menu.getStoreDao().update(store); }
@Override public Long sale(Long storeId, int amount) { Store store = menu.getStoreDao().read(storeId); Integer curAmount = store.getQuantity(); Integer newAmount = curAmount - amount; store.setQuantity(newAmount); Sales nwSale = new Sales(store, new java.util.Date(), amount); Long id = salesDao.create(nwSale); return id; }
@Override public List getNotebooksFromStore() { return menu.getStoreDao().getNotebooksFromStore(); }
@Override public List getNotebooksByCpuVendor(Vendor cpuVendor) { return menu.getStoreDao().getNotebooksByCpuVendor(cpuVendor); }
@Override public List getNotebooksGtAmount(int amount) { return menu.getStoreDao().getNotebooksGtAmount(amount); }
@Override public List getNotebooksByPortion(int size) { return menu.getStoreDao().getNotebooksByPortion(size); }
@Override public boolean updateNotebook(Notebook notebook) { return menu.getNotebookDao().update(notebook); }
@Override public boolean updateVendor(Vendor vendor) { return menu.getVendorDao().update(vendor); }
@Override public boolean updateMemory(Memory memory) { return menu.getMemoryDao().update(memory); }
@Override public boolean updateCPU(CPU cpu) { return menu.getCpuDao().update(cpu); }
public NotebookServiceImpl() { salesDao = menu.getSalesDao(); storeDao = menu.getStoreDao(); }
/** Created by ПК on 25.06.2015. */ public class NotebookServiceImpl implements NotebookService { Menu menu = Menu.getMenuInstance(); private SalesDaoImpl salesDao; private StoreDaoImpl storeDao; public NotebookServiceImpl() { salesDao = menu.getSalesDao(); storeDao = menu.getStoreDao(); } public Date dateSet(int year, int month, int day) { Calendar cal = Calendar.getInstance(); cal.set(year, month, day); Date date = cal.getTime(); return date; } @Override public Long receive(Long id, int amount, double price) { Notebook notebook = menu.getNotebookDao().read(id); Store store = new Store(notebook, amount, price); Long id2 = storeDao.create(store); return id2; } @Override public Long sale(Long storeId, int amount) { Store store = menu.getStoreDao().read(storeId); Integer curAmount = store.getQuantity(); Integer newAmount = curAmount - amount; store.setQuantity(newAmount); Sales nwSale = new Sales(store, new java.util.Date(), amount); Long id = salesDao.create(nwSale); return id; } @Override public boolean updateCPU(CPU cpu) { return menu.getCpuDao().update(cpu); } @Override public boolean updateMemory(Memory memory) { return menu.getMemoryDao().update(memory); } @Override public boolean updateVendor(Vendor vendor) { return menu.getVendorDao().update(vendor); } @Override public boolean updateNotebook(Notebook notebook) { return menu.getNotebookDao().update(notebook); } @Override public boolean removeFromStore(Store store, int amount) { Integer newQuant = store.getQuantity() - amount; store.setQuantity(newQuant); return menu.getStoreDao().update(store); } @Override public List getNotebooksByPortion(int size) { return menu.getStoreDao().getNotebooksByPortion(size); } @Override public List getNotebooksGtAmount(int amount) { return menu.getStoreDao().getNotebooksGtAmount(amount); } @Override public List getNotebooksByCpuVendor(Vendor cpuVendor) { return menu.getStoreDao().getNotebooksByCpuVendor(cpuVendor); } @Override public List getNotebooksFromStore() { return menu.getStoreDao().getNotebooksFromStore(); } @Override public Map getNotebooksStorePresent() { return menu.getStoreDao().getNotebooksStorePresent(); } @Override public Map getSalesByDays() { return menu.getSalesDao().getSalesByDays(); } }
@Override public Map getSalesByDays() { return menu.getSalesDao().getSalesByDays(); }
@Override public Map getNotebooksStorePresent() { return menu.getStoreDao().getNotebooksStorePresent(); }