예제 #1
0
        public int CreateProduct(ProductCreateInput input)
        {
            input.Name = "";
            var product = ObjectMapper.Map <Product>(input);

            return(_productRepository.InsertAndGetId(product));
        }
 public ActionResult Create([Bind(Include = "Description")] ProductCreateInput productCreate)
 {
     if (ModelState.IsValid)
     {
         _productAppService.Create(productCreate);
         return(RedirectToAction("Index"));
     }
     return(View(productCreate));
 }
예제 #3
0
        public IHttpActionResult Post([FromBody] ProductCreateInput model)
        {
            var newProduct = _productAppService.Create(model);

            if (newProduct != null)
            {
                return(Created(Request.RequestUri + "/" + newProduct.Id.ToString(), newProduct));
            }

            return(Conflict());
        }
        public ProductDetailsOutput Create(ProductCreateInput productCreateInput)
        {
            if (productCreateInput == null)
            {
                throw new ArgumentNullException("Product input cannot be null");
            }

            var entity = new Product {
                Description = productCreateInput.Description
            };

            var output = _producRepository.Insert(entity);

            _unitOfWork.Commit();

            if (output != null)
            {
                return(_mapper.Map <Product, ProductDetailsOutput>(entity));
            }

            return(null);
        }
예제 #5
0
 public virtual int CreateProduct(ProductCreateInput input)
 {
     return(_productRepository.InsertAndGetId(ObjectMapper.Map <Product>(input)));
 }
예제 #6
0
 public void CreateProductAndRollback(ProductCreateInput input)
 {
     _productRepository.Insert(ObjectMapper.Map <Product>(input));
     CurrentUnitOfWork.SaveChanges();
     throw new UserFriendlyException("This exception is thrown to rollback the transaction!");
 }