public void then_update() { var representationPut = new ProductPutRp(); representationPut.Description = NewValue; var jsonContent = HttpClientExtension.ParseModelToHttpContent(representationPut); var responsePut = _client.PutAsync(NewResourceLocation, jsonContent).Result; Assert.Equal(StatusCodes.Status200OK, (int)responsePut.StatusCode); }
public async Task <IActionResult> Put(int id, [FromBody] ProductPutRp resource) { if (!this.ModelState.IsValid) { return(this.BadRequest(this.ModelState)); } var response = await this._productComponent.UpdateProduct(id, resource); return(this.Ok()); }
/// <summary> /// Update Product /// </summary> /// <param name="model">Product Model</param> /// <returns></returns> public async Task <ProductGetRp> UpdateProduct(int id, ProductPutRp model) { var createdBy = this._identityGateway.GetIdentity(); this._dbContext.ChangeTracker.AutoDetectChangesEnabled = true; var product = await this._dbContext.Products.Include(c => c.Customer).SingleAsync(c => c.Id == id); if (product != null) { product.Update(this._datetimeGateway.GetCurrentDateTime(), createdBy, name: model.Name, description: model.Description, avatar: model.Avatar, leaders: model.Leaders); this._dbContext.Update(product); await this._dbContext.SaveChangesAsync(); } return(this._mapper.Map <ProductGetRp>(product)); }