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)); }
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); }
public virtual int CreateProduct(ProductCreateInput input) { return(_productRepository.InsertAndGetId(ObjectMapper.Map <Product>(input))); }
public void CreateProductAndRollback(ProductCreateInput input) { _productRepository.Insert(ObjectMapper.Map <Product>(input)); CurrentUnitOfWork.SaveChanges(); throw new UserFriendlyException("This exception is thrown to rollback the transaction!"); }