void buyArt() { Console.Clear(); if (active != "collector") { Console.WriteLine("please enter your collector Id"); collector = new mod.Collector(); active = "collector"; string userinput = Console.ReadLine(); try { collector.Id = int.Parse(userinput); } catch { collector.Name = userinput; } collectrepo cp = new collectrepo(_context, new mapper()); collector = cp.AddCollector(collector); if (collector.Name != "") { Console.WriteLine($"welcome {collector.Name}"); viewProfile(); } else { registerNewCollector(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(); }
void registerNewCollector(collectrepo cp) { Console.Clear(); Console.WriteLine("Please register as a Collector to continue."); collector.Name = getinput("What is your name ?"); collector.Location = getinput("What country are you ordering from?");; collector = cp.SaveCollector(collector); Console.WriteLine($"Thank you for registering! your customer id is: {collector.Id}"); }
public entity.Collector ParseCollector(mod.Collector collector) { entity.Collector c = new entity.Collector(); c.Name = collector.Name; c.Location = collector.Location; if (c.Id == null) { c.Id = collector.Id; } return(c); }
public mod.Collector SaveCollector(mod.Collector customer) { Collector tc = _context.Collectors.Find(customer.Id); if (tc == null) { tc = _context.Collectors.Add(_mapper.ParseCollector(customer)).Entity; _context.SaveChanges(); return(_mapper.ParseCollector(tc)); } tc.Name = customer.Name; tc.Location = customer.Location; _context.SaveChanges(); return(_mapper.ParseCollector(tc)); }
public mod.Collector AddCollector(mod.Collector customer) { try { if (customer.Id < 1) { //_context.Collectors.Load(); customer = _mapper.ParseCollector(_context.Collectors.Where(x => x.Name.ToLower() == customer.Name.ToLower()).FirstOrDefault()); } } catch { } if (Exists(customer.Id)) { customer = _mapper.ParseCollector(_context.Collectors.Find(customer.Id)); } else { _context.Collectors.Add(_mapper.ParseCollector(customer)); _context.SaveChanges(); } return(customer); }