public IActionResult Update(string id, [FromForm] AccessoryUpdateModel accessoryIn) { var accessory = _accessoryService.Get(id); if (accessory == null) { return(NotFound()); } var accType = _accessoryTypeService.Get(accessoryIn.AccessoryTypeId); if (accType == null) { return(StatusCode(404, new { message = "Provider Not Existed" })); } accessory.Name = accessoryIn.Name; accessory.IssuePrice = accessoryIn.IssuePrice; accessory.AccessoryType = accType; accessory.Description = accessoryIn.Description; _accessoryService.Update(id, accessory); return(NoContent()); }
public async Task <string> UpdateAccessory([FromBody] AccessoryUpdateModel accessoryModel) { if (ModelState.IsValid) { var headers = new Dictionary <string, string>(); var tokenGenerated = HttpContext.Session.GetHmacToken(); headers.Add("X-Hmac", tokenGenerated); headers.Add("X-PublicKey", HttpContext.Session.GetUserPublicKey()); string queryStr = _queryCreater.GetQueryStringFromObject(accessoryModel); var response = await HttpClientRequestFactory.Get("http://proxy.mansis.co.za:18443/SlimProxyBoot.php?" + queryStr, headers); var data = response.Content.ReadAsStringAsync().Result; return(data.ToString()); } else { throw new Exception("Model satate is not valid"); } }