예제 #1
0
        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();
            }
        }
예제 #2
0
 static void logout()
 {
     Console.Clear();
     insub     = false;
     active    = "";
     collector = new mod.Collector();
     artist    = new mod.Artist();
     seller    = new mod.Seller();
 }
예제 #3
0
        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}");
        }
예제 #4
0
 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);
 }
예제 #5
0
        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));
        }
예제 #6
0
 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);
 }