Пример #1
0
 public MainViewModel(ProductListViewModel productListModel, InventoryViewModel newInventoryModel, NewProductViewModel newProductModel)
 {
     NewInventoryModel = newInventoryModel;
     NewProductModel = newProductModel;
     ProductListModel = productListModel;
     Languages = new ObservableCollection<string>() {"en", "zh-Hans", "fr-FR"};
     LocalizeDictionary.Instance.SetCurrentThreadCulture = true;
     LocalizeDictionary.Instance.SetCultureCommand.Execute("en");
     SelectedLanguage = "en";
 }
 public void AddRemoveProductTest()
 {
     InventoryViewModel viewModel = new InventoryViewModel();
     viewModel.SelectedProduct = testProduct;
     if (viewModel.AddCommand.CanExecute(testProduct.UPC))
         viewModel.AddCommand.Execute(null);
     Assert.IsNotNull(viewModel.ProductService.GetProductByUPC(testProduct.UPC));
     if (viewModel.RemoveCommand.CanExecute(testProduct.UPC))
         viewModel.RemoveCommand.Execute(null);
     Assert.IsFalse(viewModel.ProductService.GetAllProducts().Any(x => x.UPC == testProduct.UPC));
 }
Пример #3
0
        // GET: InventoryController
        public async Task <ActionResult> Index()
        {
            var items = await _inventory.GetInventoryItemsAsync();

            _inventory.InventoryItems = items;

            var inventoryViewModel = new InventoryViewModel
            {
                Inventory = _inventory,
                Coin      = _inventory.Coin
            };

            return(View(inventoryViewModel));
        }
        public IActionResult UpdateInventory(int id)
        {
            var result    = _context.Inventories.FirstOrDefault(x => x.Id == id);
            var inventory = new InventoryViewModel();

            if (ModelState.IsValid)
            {
                inventory.Id     = result.Id;
                inventory.Name   = result.Name;
                inventory.Status = result.Status;
                inventory.Cost   = result.Cost;
            }
            return(View(inventory));
        }
        public IActionResult UpdatePost(InventoryViewModel model)
        {
            var response = iInventoryBusiness.Update(model);

            if (response.ResponseCode > 0)
            {
                return(RedirectToAction("Index"));
            }
            else
            {
                ModelState.AddModelError(string.Empty, response.ResponseMessage);
                return(View("Edit", model));
            }
        }
        // POST: api/Inventory
        public IHttpActionResult Post([FromBody] Inventory inventory)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            inventoryService.Create(inventory);
            inventory = inventoryService.GetByID(inventory.ID);

            //statusService.Save();
            InventoryViewModel inventoryView = Mapper.Map <Inventory, InventoryViewModel>(inventory);

            return(CreatedAtRoute("DefaultApi", new { id = inventory.ID }, inventoryView));
        }
Пример #7
0
        public async Task <InventoryViewModel> SoldVehicles()
        {
            var soldCars = new InventoryViewModel();

            var soldCarsInDb = _dbContext.Cars.Include(c => c.Photos).Where(c => c.SellingDate != null).ToList();

            foreach (var car in soldCarsInDb)
            {
                var viewModel = TurnCarToViewModelAsync(car);
                soldCars.Inventory.Add(await viewModel);
            }

            return(soldCars);
        }
        public ActionResult AddInventory()
        {
            var model = new InventoryViewModel();

            model.Resources = (from item in resourceRepo.FilteredGetAll()
                               select new AddressViewModel
            {
                Id = item.Id,
                Name = item.Name
            }
                               ).ToList();

            return(View(model));
        }
Пример #9
0
 private void OnInventoryClick(object sender, int e)
 {
     mSelectedItem = e;
     //mProducts.Count();
     //for(int i=0; i > mProducts.Count();i++)
     //{
     //    if(mProducts[i].Id == mInventories[mSelectedItem].ProductId)
     //    {
     //        mTextSelectedItem.Text = mProducts[i].Name;
     //    }
     //}
     mTextSelectedItem.Text = mTempInventories[e].ItemName;
     mInventory             = mTempInventories[e];
 }
Пример #10
0
        /// <summary>
        /// returns an order viewmodel based on a given inventory viewmodel that it is being created from
        /// </summary>
        /// <param name="inventoryViewModel"></param>
        /// <returns></returns>
        public OrderLineViewModel CreateOrderLine(InventoryViewModel inventoryViewModel)
        {
            OrderLineViewModel viewModel = new OrderLineViewModel()
            {
                InventoryId = inventoryViewModel.InventoryId,
                Price       = inventoryViewModel.Price,
                ProductName = inventoryViewModel.ProductName,
                Quantity    = 0,
                StoreName   = inventoryViewModel.LocationName,
                TotalPrice  = 0,
            };

            return(viewModel);
        }
Пример #11
0
        private IEnumerator Start()
        {
            TerrainManager.CreateTerrain(Vector3.zero);

            yield return(null);

            //CameraManager.AddCamera("Default Camera 1", new Vector3(-40, 115, -138), Quaternion.Euler(30, 10, 0));
            //CameraManager.AddCamera("Default Camera 2", new Vector3(33, 70.5f, -49), Quaternion.Euler(50, -32, 0));
            //CameraManager.AddCamera("Default Camera 3", new Vector3(36.5f, 180f, 138), Quaternion.Euler(63, 230, -5f));
            CameraManager.Remove("GUI Camera");

            NPCInit.Initialize();

            UIManager.Create <HUDViewModel>().IsActive         = true;
            UIManager.Create <NPCDialogueViewModel>().IsActive = false;
            UIManager.Create <BlacksmithViewModel>().IsActive  = false;
            UIManager.Create <InGameMenuViewModel>().IsActive  = false;
            UIManager.Create <RecipeViewModel>().IsActive      = false;
            //TODO: Parametrize prefab name with a UI selector
            CodeEditorViewModel codeEditorViewModel = UIManager.Create <CodeEditorViewModel>();

            StartCoroutine(codeEditorViewModel.ToggleEditorCoroutine());

            GameObject robot = RobotManager.CreateRobot("robotSphere", new Vector3(-10, 20, 0), Quaternion.identity);

            RobotManager.ActiveRobot = robot;
            RobotManager.CreateRobot("robotSphere", new Vector3(0, 20, 0), Quaternion.identity);
            RobotManager.CreateRobot("robotSphere", new Vector3(10, 20, 0), Quaternion.identity);
            RobotManager.CreateRobot("robotSphere", new Vector3(-10, 20, -10), Quaternion.identity);
            RobotManager.CreateRobot("robotSphere", new Vector3(0, 20, -10), Quaternion.identity);
            RobotManager.CreateRobot("robotSphere", new Vector3(10, 20, -10), Quaternion.identity);
            RobotManager.CreateRobot("robotSphere", new Vector3(-10, 20, -20), Quaternion.identity);
            RobotManager.CreateRobot("robotSphere", new Vector3(0, 20, -20), Quaternion.identity);
            RobotManager.CreateRobot("robotSphere", new Vector3(10, 20, -20), Quaternion.identity);

            GameObject enemyManagerPrefab = Resources.Load <GameObject>("InfrastructurePrefabs/EnemyManager");

            Instantiate(enemyManagerPrefab);

            InventoryManager.Inventory = new Inventory();
            InventoryViewModel  inventoryViewModel  = UIManager.Create <InventoryViewModel>();
            ItemDialogViewModel itemDialogViewModel = UIManager.Create <ItemDialogViewModel>();

            inventoryViewModel.IsActive  = false;
            codeEditorViewModel.IsActive = false;
            itemDialogViewModel.IsActive = false;

            CameraManager.SetCameraWall();
        }
        public IActionResult AddItem(InventoryViewModel addItemViewModel)
        {
            if (ModelState.IsValid)
            {
                Category category     = _context.Categories.Where(i => i.ID == addItemViewModel.CategoryID).FirstOrDefault();
                var      categoryName = category.Name;
                var      categoryID   = category.ID;

                DateTime purchaseDate = addItemViewModel.PurchaseDate;

                if (purchaseDate == DateTime.MinValue)
                {
                    purchaseDate = DateTime.Today;
                }

                var dupItem = _context.Items.Where(i => i.ItemID == addItemViewModel.ItemID).FirstOrDefault();

                if (dupItem == null)
                {
                    Item newItem = new Item
                    {
                        Name         = addItemViewModel.DeviceName,
                        ItemID       = addItemViewModel.BarcodeID,
                        PurchaseDate = purchaseDate,
                        Category     = categoryName,
                        CategoryID   = categoryID,
                        CheckedOut   = false
                    };

                    _context.Items.Add(newItem);
                    _context.SaveChanges();
                    return(Redirect("/Inventory"));
                }
                else
                {
                    ViewBag.message = "Duplicate Barcode";
                    return(View(addItemViewModel));
                }
            }

            IList <Category> categories = _context.Categories.ToList();

            InventoryViewModel inventoryViewModel = new InventoryViewModel
            {
                Categories = categories
            };

            return(View(inventoryViewModel));
        }
Пример #13
0
        public IActionResult Add(InventoryViewModel inventory)
        {
            try
            {
                int?customerid = HttpContext.Session.GetInt32("Customer");

                if (customerid == 0 || customerid == null)
                {
                    TempData["Messages"] = "User Not signed in";
                    TempData.Peek("Messages");
                    return(Redirect("~/"));
                }
                // check if we have enough inventory
                if (inventory.QuantityPurchase > inventory.Quantity)
                {
                    TempData["Messages"] = "Not enough items in Stock";
                    return(RedirectToAction("Add", new { store = inventory.StoreId, product = inventory.ProductId }));
                }
                if (!ModelState.IsValid)
                {
                    TempData["Messages"] = "JS not activated";
                    return(RedirectToAction("Add", new { store = inventory.StoreId, product = inventory.ProductId }));
                }

                // create an array to be serialized later
                int[] cartmodel = { inventory.StoreId, (int)customerid, inventory.ProductId, inventory.QuantityPurchase };
                // join the array so we can pass it onto a temp cart
                var cart     = String.Join(",", cartmodel);
                var tempCart = HttpContext.Session.GetString("Cart");

                // place the cart in the session
                if (String.IsNullOrEmpty(tempCart))
                {
                    HttpContext.Session.SetString("Cart", cart);
                }
                else
                {
                    HttpContext.Session.SetString("Cart", tempCart + "|" + cart);
                }
                return(RedirectToAction("Index", new { id = inventory.StoreId }));
            }
            // catch anything we couldn't catch in the if statements
            catch
            {
                TempData["Messages"] = "Something went wrong";
                TempData.Peek("Messages");
                return(Redirect("~/"));
            }
        }
Пример #14
0
 /// <summary>
 /// returns whether or not the given quantity is greater than the given inventory viewmodel based on the db
 /// </summary>
 /// <param name="quantity"></param>
 /// <param name="inventoryViewModel"></param>
 /// <returns></returns>
 public bool AmountIsGreaterThanInventory(int quantity, InventoryViewModel inventoryViewModel)
 {
     if (inventoryViewModel != null)
     {
         var dbInv = _repository.GetInventoryById(inventoryViewModel.InventoryId);
         if (dbInv != null)
         {
             if (quantity < dbInv.Quantity)
             {
                 return(false);
             }
         }
     }
     return(true);
 }
        public ActionResult Create()
        {
            var location = _locationManager.GetAll().ToList();
            var unit     = _unitManager.GetAll().ToList();
            var host     = _hostManager.GetAll().ToList();

            InventoryViewModel inventory = new InventoryViewModel
            {
                Locations = location,
                Units     = unit,
                Hosts     = host
            };

            return(View(inventory));
        }
Пример #16
0
        /// <summary>
        /// Takes in Inventory, Product, and StoreLocation to convert Inventory to InventoryViewModel.
        /// Calls second ConvertStoreLocationToStoreViewModel method to avoid infinite loop
        /// </summary>
        /// <param name="i"></param>
        /// <param name="p"></param>
        /// <param name="s"></param>
        /// <returns></returns>
        internal InventoryViewModel ConvertInventoryToInventoryViewModel(Inventory i, Product p, StoreLocation s)
        {
            InventoryViewModel inventoryViewModel = new InventoryViewModel()
            {
                InventoryId     = i.InventoryId,
                ProductQuantity = i.ProductQuantity,
                StoreLocationId = ConvertStoreLocationToStoreViewModel2(s).LocationId,
                StoreLocations  = ConvertStoreLocationToStoreViewModel2(s),
                ProductId       = i.ProductId
                                  //ProductId = _mapperClass.ConvertProductToProductViewModel(p).ProductId
                                  //Products = _mapperClass.ConvertProductToProductViewModel(p)
            };

            return(inventoryViewModel);
        }
        /// <summary>
        /// Converts an inventory into an inventory view model
        /// </summary>
        /// <param name="inventory"></param>
        /// <param name="customerGuid"></param>
        /// <returns></returns>
        public InventoryViewModel convertToInventoryModelView(Inventory inventory, Guid customerGuid)
        {
            InventoryViewModel inventoryViewModel = new InventoryViewModel()
            {
                LocationId     = inventory.Location.LocationId,
                CustomerId     = customerGuid,
                InventoryId    = inventory.InventoryId,
                ProductName    = inventory.Product.ProductName,
                Quantity       = inventory.Quantity,
                ProductPicture = ConvertByteArrayToString(inventory.Product.ByteArrayImage),
                price          = inventory.Product.Price
            };

            return(inventoryViewModel);
        }
Пример #18
0
        /// <summary>
        /// Receives the Store Location Id searches through the inventory items for all items that are in that store.
        /// Converts those inventory items into InventoryViewModels
        /// Returns a List of Inventory View Models to the View Controller
        /// </summary>
        /// <param name="locationId"></param>
        /// <returns></returns>
        public List <InventoryViewModel> GetAllStoreProductViewModels(Guid locationId)
        {
            List <Inventory>          allInventories         = _repository.GetAllInventories();
            List <InventoryViewModel> allLocationInventories = new List <InventoryViewModel>();

            foreach (Inventory x in allInventories)
            {
                if (x.LocationId == locationId)
                {
                    InventoryViewModel inventoryViewModel = _mapperClass.ConvertInventoryToInventoryViewModel(x, GetProductById(x.ProductId), GetLocationById(x.LocationId));
                    allLocationInventories.Add(inventoryViewModel);
                }
            }
            return(allLocationInventories);
        }
Пример #19
0
        public IActionResult Index()
        {
            InventoryViewModel inventoryViewModel = new InventoryViewModel();
            String             userId             = User.FindFirstValue(ClaimTypes.NameIdentifier);
            var list = _itemRepository.GetInventory(userId);

            inventoryViewModel.Inventory = new List <Item>();

            foreach (Item item in list)
            {
                inventoryViewModel.Inventory.Add(item);
            }

            return(View(inventoryViewModel));
        }
 public MainViewModel()
 {
     LoginConfig.Instance.Load();
     Proxy = new DofusRetroProxy(LoginConfig.Instance.PathDofus, new Account()
     {
         Username = LoginConfig.Instance.Username, Password = LoginConfig.Instance.Password
     });
     InteractivObject.Initialize();
     Map.Initialize();
     Spell.Initialize();
     _CharacterViewModel  = new CharacterViewModel(Proxy.Account.Character.Characteristics, Proxy.Account);
     _InventoryViewModel  = new InventoryViewModel(Proxy.Account);
     _MagicForgeViewModel = new MagicForgeViewModel(Proxy.Account);
     Navigate(_CharacterViewModel);
 }
Пример #21
0
        public IActionResult Create()
        {
            List <SelectListItem> selectList = new List <SelectListItem>();

            foreach (var product in _myContext.Products.ToList().GroupBy(x => x.Name).Select(x => x.First()).ToList())
            {
                selectList.Add(new SelectListItem(product.Name, product.Id.ToString()));
            }
            var model = new InventoryViewModel();



            ViewBag.Products = selectList;
            return(View(model));
        }
Пример #22
0
 private void dispatcherTimer_Tick(object sender, EventArgs e)
 {
     if (resetuj)
     {
         Thread.Sleep(1000);
         cekajProzor.Close();
         DataContext = new InventoryViewModel();
         stackPanelKlasicnaGitra.Visibility   = Visibility.Hidden;
         stackPanelElektricnaGitra.Visibility = Visibility.Hidden;
         stackPanelKlavijature.Visibility     = Visibility.Hidden;
         stackPanelPojacalo.Visibility        = Visibility.Hidden;
         slikaArtikla.Source = null;
         resetuj             = false;
     }
 }
Пример #23
0
        public ActionResult GetRemoved()
        {
            var items = _context.Items.Include(i => i.Category)
                        .Include(i => i.Donor)
                        .Where(i => i.IsActive == false)
                        .ToList();

            var viewModel = new InventoryViewModel
            {
                Donations = items
            };

            return(Json(items, JsonRequestBehavior.AllowGet));
            //return View("Index", viewModel);
        }
Пример #24
0
        public async Task <InventoryViewModel> GetInventory()
        {
            var inventory = new InventoryViewModel();

            var inventoryInDb = _dbContext.Cars.Include(c => c.Photos).ToList();

            foreach (var car in inventoryInDb)
            {
                var viewModel = await TurnCarToViewModelAsync(car);

                inventory.Inventory.Add(viewModel);
            }

            return(inventory);
        }
Пример #25
0
        // GET: InventoryController/Edit/5
        ///-------------------------------------------------------------------------------------------------------------------------------------
        public ActionResult Edit(int id)
        {
            int StoreID = 0;

            int.TryParse(HttpContext.Session.GetString("StoreID"), out StoreID);

            Inventory          inventory          = _buisnessLogicClass.GetInventoryFromStoreByID(id, StoreID);
            InventoryViewModel inventoryViewModel = _buisnessLogicClass.ConvertInventoryIntoVM(inventory);

            List <ProductViewModel> products = GetProductViewModelsForDropDown();

            ViewBag.Products = products;

            return(View(inventoryViewModel));
        }
Пример #26
0
        /// <summary>
        /// Throw an exception if name is exist.
        /// </summary>
        /// <param name="model">Inventory view model</param>
        public void ThrowExceptionIfExist(InventoryViewModel model)
        {
            ConditionFilter <Inventory, long> condition = new ConditionFilter <Inventory, long>
            {
                Query = (entity =>
                         entity.Code == model.Code &&
                         entity.Id != model.Id)
            };
            var existEntity = this._InventorysRepository.Get(condition).FirstOrDefault();

            if (existEntity != null)
            {
                throw new ItemAlreadyExistException((int)ErrorCodeEnum.CodeAlreadyExist);
            }
        }
Пример #27
0
        public List <InventoryViewModel> MapNeededValue(List <Inventory> inventory)
        {
            var inventories = new List <InventoryViewModel>();

            if (inventory?.Any() ?? false)
            {
                foreach (var inv in inventory)
                {
                    var invt = new InventoryViewModel();
                    invt.Id              = inv.Id;
                    invt.Name            = inv.Name;
                    invt.Brand           = inv.Brand;
                    invt.ItemModel       = inv.ItemModel;
                    invt.SerialNo        = inv.SerialNo;
                    invt.Location        = inv.Location;
                    invt.UserId          = inv.UserId;
                    invt.Quantity        = inv.Quantity;
                    invt.CreatedBy       = inv.CreatedBy;
                    invt.IsDeleted       = inv.IsDeleted;
                    invt.InventoryNumber = inv.InventoryNumber;
                    invt.InvNumber       = inv.InvNumber;
                    if (!inv.ModifiedBy.IsEmpty())
                    {
                        var user = _repo.GetUser(inv.ModifiedBy);
                        invt.ModifiedBy = user.FirstName + " " + user.MiddleName + " " + user.LastName;
                    }
                    else
                    {
                        var user = _repo.GetUser(inv.CreatedBy);
                        invt.ModifiedBy = user.FirstName + " " + user.MiddleName + " " + user.LastName;
                    }
                    if (inv.ModifiedDate != null)
                    {
                        invt.ModifiedDate = inv.ModifiedDateConverted;
                    }
                    else
                    {
                        inv.ModifiedDate = inv.CreatedDateConverted;
                    }
                    if (inv.User != null)
                    {
                        invt.Costodian = inv.User.FirstName + " " + inv.User.MiddleName + " " + inv.User.LastName;
                    }
                    inventories.Add(invt);
                }
            }
            return(inventories);
        }
        // GET: Inventory
        public ActionResult Index(int?PageNumber, int?brandId)
        {
            unitOfWork = new EFUnitOfWork(db);

            InventoryViewModel ıvm = new InventoryViewModel();

            ıvm.FilterModel = new FilterModel();

            #region Vehicle List Model Binding
            List <VehicleModel> vhList = new List <VehicleModel>();

            vhList = unitOfWork.GetRepository <Vehicle>().GetAll(v => v.Rentable == false).ProjectTo <VehicleModel>().ToList();

            if (brandId != null)
            {
                vhList = vhList.Where(vh => vh.BrandId == brandId).ToList();
            }

            ıvm.FilterModel.ResultCount = vhList.Count();

            ıvm.PagedVehicleModels = vhList.ToPagedList(PageNumber ?? 1, 6);
            #endregion

            #region Type Model  Brand Binding
            ıvm.TypeModels  = unitOfWork.GetRepository <Type>().GetAll().ProjectTo <TypeModel>().ToList();
            ıvm.BrandModels = new List <BrandModel>();
            ıvm.ModelModels = new List <ModelModel>();
            #endregion

            #region Filter Model Binding

            ıvm.FilterModel.Filtered = false;

            #endregion

            #region Brand Categories Model Binding
            ıvm.BrandModelModels = unitOfWork.GetRepository <Brand>().GetAll().ProjectTo <BrandModelsModel>().ToList();

            foreach (var BrandModelModel in ıvm.BrandModelModels)
            {
                BrandModelModel.brandModels = unitOfWork.GetRepository <Model>()
                                              .GetAll(ty => ty.BrandId == BrandModelModel.BrandId).ProjectTo <ModelModel>().ToList();
            }
            #endregion

            unitOfWork.Dispose();
            return(View(ıvm));
        }
Пример #29
0
        public Inventory CreateNewInventory(InventoryViewModel inventoryViewModel, int ProductID, int StoreID)
        {
            Location StoreInventory = GetStoreLocationIncludingInventoryAndProduct(StoreID);

            // Verify if its exist
            if (StoreInventory.Inventory.Exists(x => x.Product.ProductID == ProductID))
            {
                //We will add the product
                //Validate if it it in the limit..
                Inventory inventory = StoreInventory.Inventory.First(x => x.Product.ProductID == ProductID);


                if (inventory.Quantity + inventoryViewModel.Quantity > 100)
                {
                    //It is the defined limit, throw a exception
                    throw new Exception("Error while updating the product. The Product limit is 99.");
                }
                else
                {
                    // Proceed to update the product
                    StoreInventory.Inventory.First(x => x.Product.ProductID == ProductID).Quantity += inventoryViewModel.Quantity;

                    UpdateLocation(StoreInventory);
                }
            }
            else
            {
                //Is a new inventory
                Inventory inventory = new Inventory()
                {
                    Product  = this.GetProductByID(ProductID),
                    Quantity = inventoryViewModel.Quantity
                };

                StoreInventory.Inventory.Add(inventory);

                _storeDbContext.Locations.Update(StoreInventory);

                SaveChangesToDb();
            }


            Inventory returnInv = GetStoreLocationIncludingInventoryAndProduct(StoreID)
                                  .Inventory
                                  .FirstOrDefault(x => x.Product.ProductID == ProductID);

            return(returnInv);
        }
Пример #30
0
        public ActionResult Vehicles()
        {
            var repo = VehicleRepositoryFactory.GetVehicleRepository();

            var yearList = repo.GetYearList("");

            var salePriceList = repo.GetSalePriceList("");

            var model = new InventoryViewModel()
            {
                YearList      = yearList,
                SalePriceList = salePriceList
            };

            return(View(model));
        }
Пример #31
0
        /// <summary>
        /// Delete inventory record
        /// </summary>
        /// <param name="inventoryViewModel"></param>
        /// <returns></returns>
        public static bool DeleteInventories(InventoryViewModel inventoryViewModel)
        {
            bool result = false;

            try
            {
                Inventory inventory = ToInventory(inventoryViewModel);
                DbFactory.Instance.context.Inventories.Remove(inventory);
                DbFactory.Instance.context.SaveChanges();
                result = true;
            }
            catch (Exception e)
            {
            }
            return(result);
        }
Пример #32
0
        public ActionResult Index()
        {
            var repo = VehicleRepositoryFactory.GetVehicleRepository();

            var yearList = repo.GetYearList("");           // Empty argument will get list of both New and Used Type

            var salePriceList = repo.GetSalePriceList(""); // Empty argument will get list of both New and Used Type

            var model = new InventoryViewModel()
            {
                YearList      = yearList,
                SalePriceList = salePriceList
            };

            return(View(model));
        }
 public void Initialize()
 {
     mockProduct = new Mock<IProductService>();
     mockProduct.Setup(x => x.GetAllProducts()).Returns(new List<ProductDTO>()
         {
             new ProductDTO()
             {
                 UPC = "123",
                 BrandID = 1,
                 CategoryListID = 1,
                 Description = "Test",
                 IsTaxable = true,
                 HasDeposit = true,
                 MinimumAge = 1,
                 Name = "Test Item",
                 MinOnHand = 0,
                 OnHand = 1,
                 SellingPrice = 1,
                 StoreCost = 2,
             }
         });
     mockBrand = new Mock<IBrandService>();
     mockBrand.Setup(x => x.GetAllBrands()).Returns(new List<BrandDTO>()
     {
         new BrandDTO()
         {
             Id = 1,
             Name = "Test1"
         },
         new BrandDTO()
         {
             Id = 2,
             Name = "Test2"
         }
     });
     mockCategory = new Mock<ICategoryService>();
     mockCategory.Setup(x => x.GetAll()).Returns(new List<CategoryDTO>()
     {
         new CategoryDTO()
         {
             Id = 1,
             Name = "Test Category",
             Description = "A test category"
         },
     });
     testProduct = new ObservableProduct(new ProductDTO
     {
         UPC = "555",
         BrandID = 1,
         CategoryListID = 1,
         Description = "Test",
         IsTaxable = true,
         HasDeposit = true,
         MinimumAge = 1,
         Name = "Test Item",
         MinOnHand = 0,
         OnHand = 1,
         SellingPrice = 1,
         StoreCost = 2
     });
     viewModel = new InventoryViewModel(mockProduct.Object, mockBrand.Object, mockCategory.Object);
 }
 public AppreciateAppreciation(InventoryViewModel model)
 {
     InitializeComponent();
     this.PastAppreciations.ItemsSource = model.AppreciationList;
     this.MyDate.SelectedDate = DateTime.Now;
 }
Пример #35
0
 private void SaveBtn_OnClick(object sender, RoutedEventArgs e)
 {
     var items = new InventoryViewModel[this.InventoryGrid.Items.Count];
     this.InventoryGrid.Items.CopyTo(items, 0);
     MainWindow.StorageService.UpdateInventory(new List<InventoryViewModel>(items));
 }