public async Task <CreateCategoryResponseModel> CreateCategory(CreateCategoryRequestModel createCategoryRequestModel) { if (createCategoryRequestModel == null) { throw new ArgumentNullException(nameof(createCategoryRequestModel)); } var createCategoryResponseModel = new CreateCategoryResponseModel(); try { await _inMemoryStorage.Save( new Category { Id = createCategoryRequestModel.Id, Description = createCategoryRequestModel.Description, Name = createCategoryRequestModel.Name, UserId = createCategoryRequestModel.UserId, }, true) .ConfigureAwait(false); } catch (Exception ex) { createCategoryResponseModel.ErrorMessage = ex.Message; } return(createCategoryResponseModel); }
// Category public override async Task <GovDeliveryResponseModel <CreateCategoryResponseModel> > CreateCategoryAsync(CreateCategoryRequestModel requestModel) { var responseModel = new CreateCategoryResponseModel { ToParam = "12345", CategoryUri = $"/api/account/{accountCode}/categories/12345.xml", }; var httpResponse = new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = SerializationUtils.ModelToStringContent(responseModel) }; return(new GovDeliveryResponseModel <CreateCategoryResponseModel> { HttpResponse = httpResponse, Data = await SerializationUtils.ResponseContentToModel <CreateCategoryResponseModel>(httpResponse.Content) }); }