Beispiel #1
0
            private async Task<IHttpActionResult> SaveAssetAndGetId(AssetCreationVm assetToSave)
            {
                var createdAsset = MapVmToAsset(assetToSave);
                var isCreated = await Task.FromResult(_repository.Create(createdAsset));
             
                if (!isCreated) return BadRequest("Unable to create new Asset for :  " + assetToSave.AssetTicker.Trim());

                //TODO: Use routeData for URL.
               return Created("http://localhost/Pims.Web.Api/api/Asset/", createdAsset);
            }
Beispiel #2
0
 private static Asset MapVmToAsset(AssetCreationVm sourceVm)
 {
     return new Asset {
         InvestorId = new Guid(sourceVm.AssetInvestorId),
         AssetClassId = new Guid(sourceVm.AssetClassificationId),
         ProfileId = sourceVm.ProfileToCreate.ProfileId,
         AssetId = sourceVm.AssetIdentification == null ? new Guid() : new Guid(sourceVm.AssetIdentification),
         LastUpdate = DateTime.Now
     };
 }