public void sellArt() { Console.Clear(); if (active != "seller") { Console.WriteLine("please enter your seller Id"); seller = new mod.Seller(); active = "seller"; string userinput = Console.ReadLine(); try { seller.Id = int.Parse(userinput); } catch { seller.name = userinput; } SellerRepo cp = new SellerRepo(_context, new SellerMapper()); seller = cp.AddSeller(seller); if (seller.name != "") { Console.WriteLine($"welcome {seller.name}"); viewProfile(); } else { registerNewSeller(cp); } } insub = true; while (insub) { subMenu(); } }
static void logout() { Console.Clear(); insub = false; active = ""; collector = new mod.Collector(); artist = new mod.Artist(); seller = new mod.Seller(); }
public entity.Seller Parse(mod.Seller seller) { entity.Seller c = new entity.Seller(); c.Name = seller.name; if (c.Id == null) { c.Id = seller.Id; } return(c); }
public void Save(mod.Seller seller) { Seller tc = _context.Sellers.Find(seller.Id); if (tc == null) { tc = _context.Sellers.Add(_mapper.Parse(seller)).Entity; _context.SaveChanges(); } tc.Name = seller.name; _context.SaveChanges(); }
public mod.Seller AddSeller(mod.Seller newSeller) { try { if (newSeller.Id < 1) { //_context.Collectors.Load(); newSeller = _mapper.Parse(_context.Sellers.Where(x => x.Name.ToLower() == newSeller.name.ToLower()).FirstOrDefault()); } } catch { } if (Exists(newSeller.Id)) { newSeller = _mapper.Parse(_context.Sellers.Find(newSeller.Id)); } else { Seller addedSeller = _context.Sellers.Add(_mapper.Parse(newSeller)).Entity; _context.SaveChanges(); newSeller = _mapper.Parse(addedSeller); } return(newSeller); }