public void CreateDummy() { ViewModel.Product product = new ViewModel.Product() { ID = Guid.NewGuid(), Maker = "Yonex", Name = "BatMinton", Price = 120.00 }; ViewModel.ProductDetail details = new ViewModel.ProductDetail() { ID = Guid.NewGuid(), Description = "Awesome Badminton", ProductID = product.ID }; try { DataModel.Product dbProd = _mapper.Map <DataModel.Product>(product); DataModel.ProductDetail dbProdDetail = _mapper.Map <DataModel.ProductDetail>(details); _unitOfWork.productRepository.InsertProduct(dbProd); _unitOfWork.productDetail.Insert(dbProdDetail); _unitOfWork.Commit(); } catch (Exception ex) { //_logger.LogError("Error when creating uow transaction, thereby reverting back. Error: {}", ex.Message); _unitOfWork.Rollback(); // return Task.FromResult(new Author()); } // return _unitOfWork.AuthorRepository.GetByName(fyodor.Name); }
public ViewModel.Product Get(Guid id) { DataModel.Product product = _unitOfWork.productRepository.GetProductByID(id); return(_mapper.Map <ViewModel.Product>(product)); }