Пример #1
0
 public void Update(InventoriesModel inventory)
 {
     InventoryId    = inventory.InventoryId;
     Name           = inventory.Name;
     Description    = inventory.Description;
     QuantityOnHand = inventory.QuantityOnHand;
 }
        public ActionResult GetById(long?productId)
        {
            var inventorylist = new AllProducts();

            if (productId != null)
            {
                var groupName = (GroupName)productId;
                var query     = new InventoryQuery().GetInventories(groupName.ToString());

                if (query != null)
                {
                    foreach (var inventory in query)
                    {
                        var inverntoryModel = new InventoriesModel()
                        {
                            Id          = inventory.Id,
                            GroupName   = groupName.ToString(),
                            ItemsCount  = inventory.ItemsCount,
                            ProductName = inventory.ProductName
                        };
                        inventorylist.InventoriesModels.Add(inverntoryModel);
                    }
                }
            }

            return(PartialView("ProductsGrid", inventorylist));
        }
Пример #3
0
        public IHttpActionResult PostInventory(InventoriesModel inventory)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var dbInventory = new Inventory();

            _inventoryRepository.Add(dbInventory);

            _unitOfWork.Commit();

            inventory.InventoryId = dbInventory.InventoryId;

            return(CreatedAtRoute("DefaultApi", new { id = inventory.InventoryId }, inventory));
        }
Пример #4
0
        public IHttpActionResult PutInventory(int id, InventoriesModel inventory)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != inventory.InventoryId)
            {
                return(BadRequest());
            }

            Inventory dbInventory = _inventoryRepository.GetById(id);

            dbInventory.Update(inventory);

            _inventoryRepository.Update(dbInventory);

            try
            {
                _unitOfWork.Commit();
            }
            catch (Exception)
            {
                if (!InventoryExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Пример #5
0
 public Inventory(InventoriesModel inventory)
 {
     this.Update(inventory);
 }