예제 #1
0
        public async Task <Product> AddProductAsync(Product product)
        {
            Item item = null;

            try
            {
                item         = product.ToItem();
                item.AddedOn = DateTime.UtcNow;
                using (InventoryContextScope contextScope = new InventoryContextScope())
                {
                    ItemRepo itemRepo = new ItemRepo(contextScope);
                    item = itemRepo.Add(item);
                    await contextScope.Complete();
                }
            }
            catch (SqlException e)

            {
                Logger.Error(e.Message, e);
                throw e;
            }
            catch (Exception e)
            {
                Logger.Error(e.Message, e);

                throw e;
            }
            return(item?.ToProduct());
        }