Exemple #1
0
        public IHttpActionResult PutInventory(Guid id, InventorylogViewModel inventory)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

            try
            {
                _inventorylogRepository.Edit(inventory.ToModel());
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!InventoryExist(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Exemple #2
0
        public IHttpActionResult PostInventory(InventorylogViewModel inventory)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }



            try
            {
                _inventorylogRepository.Add(inventory.ToModel());
            }
            catch (DbUpdateException)
            {
                if (InventoryExist(inventory.Id))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = inventory.Id }, inventory));
        }
Exemple #3
0
        public IHttpActionResult GetInventory(Guid id)
        {
            InventorylogViewModel inventory = new InventorylogViewModel(_inventorylogRepository.GetSingle(e => e.Id == id));

            if (inventory == null)
            {
                return(NotFound());
            }

            return(Ok(inventory));
        }