public ShipmentTypeDto PutShipmentType( Guid key, ShipmentTypeRequestModel requestModel) { var shipmentType = _shipmentService.GetShipmentType(key); if (shipmentType == null) { throw new HttpResponseException(HttpStatusCode.NotFound); } var updatedShipmentType = _shipmentService.UpdateShipmentType( requestModel.ToShipmentType(shipmentType)); return updatedShipmentType.ToShipmentTypeDto(); }
public HttpResponseMessage PostShipmentType( ShipmentTypeRequestModel requestModel) { var createdShipmentTypeResult = _shipmentService .AddShipmentType(requestModel.ToShipmentType()); if (!createdShipmentTypeResult.IsSuccess) { return new HttpResponseMessage(HttpStatusCode.Conflict); } var response = Request.CreateResponse(HttpStatusCode.Created, createdShipmentTypeResult.Entity.ToShipmentTypeDto()); response.Headers.Location = new Uri(Url.Link("DefaultHttpRoute", new { key = createdShipmentTypeResult.Entity.Key })); return response; }