public IActionResult UpdateProductionArea(Guid productionAreaId, [FromBody] ProductionAreaCRUD updatedProductionArea) { if (productionAreaId == null || productionAreaId == Guid.Empty || EqualityComparer <ProductionAreaCRUD> .Default.Equals(updatedProductionArea, default(ProductionAreaCRUD)) ) { return(BadRequest()); } var _updatedProductionArea = _mapper.Map <ProductionArea>(updatedProductionArea); var resultProductionAreaUpdated = _productionAreaRepository.UpdateProductionArea(productionAreaId, _updatedProductionArea); if (!resultProductionAreaUpdated) { return(NotFound()); } _updatedProductionArea.Id = productionAreaId; _productionAreaRepository.Save(); var productionAreaTO = _mapper.Map <ProductionAreaTO>(_updatedProductionArea); return(CreatedAtRoute("GetProductionArea" , new { productionAreaId = productionAreaTO.Id } , productionAreaTO )); }
public IActionResult CreateProductionArea([FromBody] ProductionAreaCRUD newProductionArea) { if (newProductionArea == null || EqualityComparer <ProductionAreaCRUD> .Default.Equals(newProductionArea, default(ProductionAreaCRUD))) { return(BadRequest()); } var _productionArea = _mapper.Map <ProductionArea>(newProductionArea); var resultProductionAreaCreated = _productionAreaRepository.CreateProductionArea(_productionArea); if (!resultProductionAreaCreated) { return(NotFound()); } _productionAreaRepository.Save(); var productionAreaTO = _mapper.Map <ProductionAreaTO>(_productionArea); return(CreatedAtRoute("GetProductionArea" , new { productionAreaId = productionAreaTO.Id } , productionAreaTO )); }