public async Task <IActionResult> GetFields(int id)
        {
            IEnumerable <Field> fields = await _fieldService.GetAllFieldsForDataset(id);

            IEnumerable <DatasetFieldViewModel> viewModels = new DatasetFieldViewModel().MapToEnumerable(fields);

            return(Json(viewModels));
        }
        public async Task <IActionResult> Update(int id, [FromBody] DatasetFieldViewModel datasetFieldModel)
        {
            try
            {
                var fieldToUpdate = new DatasetFieldViewModel().Map(datasetFieldModel, id);

                var field = await _fieldService.Update(fieldToUpdate.Id, fieldToUpdate);

                return(Json(new DatasetFieldViewModel().Map(field)));
            }
            catch (Exception e)
            {
                Log.Error(e, "Could not update field {fieldId} on dataset {datasetId}", datasetFieldModel.Id, id);
                return(StatusCode(StatusCodes.Status500InternalServerError));
            }
        }
        public async Task <IActionResult> CreateFieldForDataset(int id, [FromBody] DatasetFieldViewModel model)
        {
            try
            {
                var field         = new DatasetFieldViewModel().Map(model, id);
                var fieldToCreate = await _fieldService.Create(field);

                var result = Json(new DatasetFieldViewModel().Map(fieldToCreate));
                result.StatusCode = StatusCodes.Status201Created;

                return(result);
            }
            catch (Exception e)
            {
                Log.Error(e, "Could not create field for dataset with id: {datasetId}", id);
                return(StatusCode(StatusCodes.Status500InternalServerError));
            }
        }