public IHttpActionResult Create(ProductDto productDto) { if (!ModelState.IsValid) { return(BadRequest()); } var product = Mapper.Map <ProductDto, Product>(productDto); _service.AddOrUpdate(product); _service.Complete(); productDto.Id = product.Id; return(Created(new Uri(Request.RequestUri + "/" + product.Id), productDto)); }
public async Task <Operate> AddOrUpdate(ProductModel model) { //TODO need to confirm authentication pipeline is used var userName = User.Identity.Name; return(await _productService.AddOrUpdate(model, userName)); }
// PUT: api/Product/5 public HttpResponseMessage Put(Product product) { //var ser = service; // _repo.UdpateService(service);/* if (_service.AddOrUpdate(product)) { return(Request.CreateResponse(HttpStatusCode.OK, product)); } else { return(Request.CreateResponse(HttpStatusCode.NotModified)); } }
public void AddOrUpdate_Product_Returns_True() { // Arrange var product = new Product { Mass = 50 }; var mockRepo = new Mock <IProductRepository>(); mockRepo.Setup(m => m.AddOrUpdate(product)) .Returns( true ); var mockUnitOfWork = new Mock <IUnitOfWork>(); mockUnitOfWork.Setup(uow => uow.Products).Returns(mockRepo.Object); ProductService service = new ProductService(mockUnitOfWork.Object); // Act var actual = service.AddOrUpdate(product); // Assert Assert.IsTrue(actual); }
private void SaveChanges(object sender, EventArgs e) { _productService.AddOrUpdate(_activeProductList); FormateProductGrid(); }
// Save the DTO private void btnSaveChanges_Click(object sender, EventArgs e) { _unitsService.AddOrUpdate(_products); ctx.SaveChanges(); LoadProducts(_selectedJob.JobID); }