public async Task <IActionResult> Update([FromRoute] Guid additionalCostId, [FromBody] AdditionalCostRequest request) { var additionalCost = await _additionalCostsService.GetByIdAsync(additionalCostId); additionalCost.Description = request.Description; additionalCost.Price = request.Price; additionalCost.Date = request.Date; var updated = await _additionalCostsService.UpdateAsync(additionalCost); if (updated) { return(Ok(AdditionalCostToAdditionalCostResponse(additionalCost))); } return(NotFound()); }
public async Task <IActionResult> Create([FromBody] AdditionalCostRequest customerRequest) { var additionalCost = new AdditionalCost { Description = customerRequest.Description, Price = customerRequest.Price, Date = customerRequest.Date }; await _additionalCostsService.CreateAsync(additionalCost); var baseurl = $"{HttpContext.Request.Scheme}://{HttpContext.Request.Host.ToUriComponent()}"; var locationuri = baseurl + "/" + ApiRoutes.AdditionalCosts.Get.Replace("{additionalCostId}", additionalCost.Id.ToString()); var response = AdditionalCostToAdditionalCostResponse(additionalCost); return(Created(locationuri, response)); }