/// <summary>
 ///
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public Asset FindAssetByInventorySearchQuery(InventoryFormViewModel model)
 {
     return(_db.Assets
            .DefaultIfEmpty()
            .Where(a => a.AssetKey == model.ItemKey)
            .Where(a => a.InventoryOwner == model.InventoryOwner)
            .Where(a => a.ClientSite.Id == model.SelectedClientSiteId)
            .SingleOrDefault(a => a.Location.Id == model.SelectedLocationId));
 }
Esempio n. 2
0
        public static int CheckSimilarVinExist(string stock, InventoryFormViewModel inventory, DealershipViewModel dealer)
        {
            if (inventory.CarsList.Any(o => o.Vin.Contains(stock)))
            {
                int numberofResult = inventory.CarsList.Count(o => o.Vin.Contains(stock));
                return(numberofResult);
            }

            return(0);
        }
        public ViewResult TakeInventory()
        {
            var ivvm = new InventoryFormViewModel
            {
                Locations     = _repo.GetLocations(),
                ClientSites   = _repo.GetClientSites(),
                InventoryDate = DateTime.Now.ToString("MM/dd/yyyy"),
                InventoriedBy = "Robert Newton"             //Default used since we don't have AD connected
            };

            return(View(ivvm));
        }
        public void InventoryViewModelToFormData_FullData()
        {
            //Arrange
            var iViewModel = new InventoryFormViewModel {
                Id              = 5,
                ShipDate        = new DateTime(2012, 1, 2),
                BatchNumber     = 120,
                QuantityShipped = 4.5m,
                ReceiptDate     = new DateTime(2012, 2, 1)
            };
            var iFormData = CreateEmptyInventoryFormData();

            //Act
            formController.MapInventoryViewModelToFormData(iViewModel, iFormData);

            //Assert
            Assert.That(iFormData.BatchNumber.Value, Is.EqualTo("120"));
            Assert.That(iFormData.ShipDate.Value, Is.EqualTo(new DateTime(2012, 1, 2).ToString(CultureInfo.InvariantCulture)));
            Assert.That(iFormData.ReceiptDate.Value, Is.EqualTo(new DateTime(2012, 2, 1).ToString(CultureInfo.InvariantCulture)));
            Assert.That(iFormData.QuantityShipped.Value, Is.EqualTo(4.5m.ToString(CultureInfo.InvariantCulture)));
        }
        public PartialViewResult TakeInventory(InventoryFormViewModel model)
        {
            if (ModelState.IsValid)
            {
                var item = _repo.FindAssetByInventorySearchQuery(model);

                if (item != null && DateTime.Now.AddDays(-90) < item.InventoryDate)
                {
                    ModelState.AddModelError("InventoryDate", "Possible Duplicate Item");
                }

                ViewBag.ItemKey        = model.ItemKey;
                ViewBag.InventoryOwner = model.InventoryOwner;
                ViewBag.InventoriedBy  = "Robert Newton"; //Default used since we don't have AD connected

                return(PartialView("_takeInventorySearchResults", item));
            }

            Response.StatusCode = 404;
            model.Locations     = _repo.GetLocations();
            model.ClientSites   = _repo.GetClientSites();
            return(PartialView("_takeInventoryForm", model));
        }