public void UpdateSushi(Sushi sushi) { try { var exiStsushi = sushis.SingleOrDefault(item => item.Id == sushi.Id); if (exiStsushi == null) { throw new NullReferenceException(); } exiStsushi.Name = sushi.Name; exiStsushi.HalfOrFull = sushi.HalfOrFull; exiStsushi.Things = sushi.Things; exiStsushi.Weight = sushi.Weight; exiStsushi.Cost = sushi.Cost; } catch (NullReferenceException ex) { MyLog.Logs($"Something wrong!\n{ex.Message}\n{ex.StackTrace}"); } catch (Exception ex) { MyLog.Logs($"Something wrong!\n{ex.Message}\n{ex.StackTrace}"); } }
public void CreateSushi(Sushi sushi) { sushi.Id = _idCounter; _idCounter++; sushis.Add(sushi); }
public static SushiRepository MenuMaker(SushiRepository sushiRepository) { Sushi phila = new Sushi("Philadelphia", 250.0f, 12.50f, 8, true); sushiRepository.CreateSushi(phila); Sushi califa = new Sushi("California", 210.0f, 9.80f, 8, true); sushiRepository.CreateSushi(califa); Sushi nigiriSiakie = new Sushi("Nigiri siakie", 80.0f, 5.0f, 2, false); sushiRepository.CreateSushi(nigiriSiakie); Sushi gunkanTekka = new Sushi("Gunkans tekka", 80.0f, 6.50f, 2, false); sushiRepository.CreateSushi(gunkanTekka); return(sushiRepository); }
public Sushi GetSushiById(int id) { try { Sushi sushi = sushis.SingleOrDefault(item => item.Id == id); if (sushi == null) { Console.WriteLine("Sorry, no product information was found. Select another product."); } return(sushi == null ? null : (Sushi)sushi); } catch (Exception ex) { Console.WriteLine("Sorry, something happened. Select another product."); MyLog.Logs($"Something wrong!\n{ex.Message}\n{ex.StackTrace}"); return(null); } }