예제 #1
0
        public override int AddNewItem(Video video)
        {
            var itemInput    = new GetItemByIdInput();
            var barcodeInput = new SetItemBarcodeInput();
            var updateInput  = new UpdateItemInput();

            var input = new VideoDto.AddNewVideoInput
            {
                Video = new VideoDto(video)
            };

            using (var repo = new VideoRepository())
            {
                var app = new VideoAppService(repo);
                itemInput.Id = app.AddNewVideo(input).Id;
            }
            using (var itemRepo = new ItemRepository())
            {
                var app      = new ItemAppService(itemRepo);
                var thisItem = app.GetItemById(itemInput);
                barcodeInput.Item = thisItem.Item;
                var barcodeOutput = app.SetItemBarcode(barcodeInput);
                thisItem.Item.Barcode = barcodeOutput.Barcode;
                updateInput.Item      = thisItem.Item;
                app.UpdateItem(updateInput);
            }
            return(itemInput.Id);
        }
예제 #2
0
        public override int AddNewItem(Book book)
        {
            var itemInput    = new GetItemByIdInput();
            var barcodeInput = new SetItemBarcodeInput();
            var updateInput  = new UpdateItemInput();

            var input = new AddNewBookInput
            {
                Book = new BookDto(book)
            };

            using (var repo = new BookRepository())
            {
                var app = new BookAppService(repo);
                itemInput.Id = app.AddNewBook(input).Id;
            }
            using (var itemRepo = new ItemRepository())
            {
                var app      = new ItemAppService(itemRepo);
                var thisItem = app.GetItemById(itemInput);
                barcodeInput.Item = thisItem.Item;
                var barcodeOutput = app.SetItemBarcode(barcodeInput);
                thisItem.Item.Barcode = barcodeOutput.Barcode;
                updateInput.Item      = thisItem.Item;
                app.UpdateItem(updateInput);
            }
            return(itemInput.Id);
        }
예제 #3
0
        public virtual int AddNewItem(T genericItem)
        {
            var itemInput    = new GetItemByIdInput();
            var barcodeInput = new SetItemBarcodeInput();
            var updateInput  = new UpdateItemInput();

            var input = new AddNewItemInput <T>
            {
                Item = new GenericItemDto <T>(genericItem)
            };

            using (var repo = new GenericItemRepositoryBase <T>())
            {
                var app = new GenericItemAppService <T>(repo);
                itemInput.Id = app.AddNewItem(input).Id;
            }
            using (var itemRepo = new ItemRepository())
            {
                var app      = new ItemAppService(itemRepo);
                var thisItem = app.GetItemById(itemInput);
                barcodeInput.Item = thisItem.Item;
                var barcodeOutput = app.SetItemBarcode(barcodeInput);
                thisItem.Item.Barcode = barcodeOutput.Barcode;
                updateInput.Item      = thisItem.Item;
                app.UpdateItem(updateInput);
            }
            return(itemInput.Id);
        }
예제 #4
0
        public Item GetItemById(int id)
        {
            var input = new GetItemByIdInput
            {
                Id = id
            };

            using (var repo = new ItemRepository())
            {
                var app    = new ItemAppService(repo);
                var output = app.GetItemById(input);
                return(output.Item.ConvertToItem());
            }
        }