public Model.Location GetLocationById(int id)
 {
     Entity.StoreFront found = _context.StoreFronts
                               .AsNoTracking()
                               .FirstOrDefault(loc => loc.Id == id);
     return(_mapper.ParseStore(found));
 }
 public Model.Location GetLocationByName(string name)
 {
     Entity.StoreFront found = _context.StoreFronts
                               .AsNoTracking()
                               .FirstOrDefault(loc => loc.SName == name);
     return(_mapper.ParseStore(found));
 }
        public Model.Location ParseStore(Entity.StoreFront store)
        {
            if (store is null)
            {
                return(null);
            }
            List <Model.Inventory> inventory = new List <Model.Inventory>();
            List <Model.Order>     orders    = new List <Model.Order>();

            if (store.Inventories is not null)
            {
                foreach (Entity.Inventory inven in store.Inventories)
                {
                    inventory.Add(ParseInventory(inven));
                }
            }
            if (store.Orders is not null)
            {
                foreach (Entity.Order order in store.Orders)
                {
                    orders.Add(ParseOrder(order));
                }
            }
            return(new Model.Location
            {
                Id = store.Id,
                Name = store.SName,
                Address = store.SAddress,
                Inventory = inventory,
                Orders = orders
            });
        }
        public Model.Location AddNewLocation(Model.Location loc)
        {
            Entity.StoreFront locToAdd = _context.StoreFronts
                                         .Add(_mapper.ParseStore(loc, true)).Entity;

            _context.SaveChanges();
            _context.ChangeTracker.Clear();
            return(_mapper.ParseStore(locToAdd));
        }