/// <summary> /// Rimozione Prodotto /// </summary> /// <param name="id"></param> /// <param name="numero"></param> /// <returns></returns> public int RimuoviProdotto(int id, int numero) { bool exist = Prodotti.Any(p => p.Id == id); if (exist) { List <DB.Storico> s = Storici.Where(pr => pr.ProdottoId == id).Take(numero).ToList(); if (s != null) { Storici.RemoveRange(s); } return(SaveChanges()); } else { return(-1); } }
public int[] CreaNuovoProdotto(Prodotto p, int pezzi = 0) { int[] ret = new int[2]; bool exist = Prodotti.Any(pr => pr.CodiceArticolo == p.CodiceArticolo); if (!exist) { Prodotti.Add(p); ret[0] = SaveChanges(); AggiungiProdotto(p.Id, pezzi); ret[1] = SaveChanges(); return(ret); } else { return(new int[] { -1, -1 }); } }
public int AggiungiProdotto(string codice, int numero) { bool exist = Prodotti.Any(p => p.CodiceArticolo == codice); if (exist) { DB.Prodotto p = Prodotti.Single(i => i.CodiceArticolo == codice); for (int i = 0; i < numero; i++) { Storici.Add(new DB.Storico() { ProdottoId = p.Id, DataInserimento = DateTime.Now, }); } return(SaveChanges()); } else { return(-1); } }
public int[] CreaNuovoProdotto(string codice, int produttoreId, int pezzi = 0, decimal costoAquisto = 0, decimal prezzoVendita = 0) { int[] ret = new int[2]; bool exist = Prodotti.Any(p => p.CodiceArticolo == codice); if (!exist) { DB.Prodotto p = new DB.Prodotto() { ProduttoreId = produttoreId, CodiceArticolo = codice.Trim().ToUpper() }; Prodotti.Add(p); ret[0] = SaveChanges(); AggiungiProdotto(p.Id, pezzi); ret[1] = SaveChanges(); return(ret); } else { return(new int[] { -1, -1 }); } }