コード例 #1
0
        public IActionResult Update(DataSourceTypeDTO dataSourceTypeDTO, int Id)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState.GetErrorMessage()));
            }
            else
            {
                IDataResult <DataSourceType> result = _iDataSourceTypeService.GetById(Id);
                if (result == null)
                {
                    return(BadRequest(result.Message));
                }
                else
                {
                    _iMapper = DataSourceTypeMapping.GetMapper().CreateMapper();
                    DataSourceType dataSource = _iMapper.Map <DataSourceTypeDTO, DataSourceType>(dataSourceTypeDTO);

                    IResult updateResult = _iDataSourceTypeService.Update(dataSource);

                    if (updateResult.Success)
                    {
                        return(Ok(updateResult.Message));
                    }
                    return(BadRequest(updateResult.Message));
                }
            }
        }
コード例 #2
0
        public async Task <IActionResult> UpdateAsync(DataSourceTypeDTO dataSourceTypeDTO, int Id)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState.GetErrorMessage()));
            }
            else
            {
                IDataResult <DataSourceType> dataResult = await _iDataSourceTypeService.FindByIdAsync(Id);

                if (dataResult.Data == null)
                {
                    return(BadRequest(dataResult.Message));
                }
                _iMapper = DataSourceTypeMapping.GetMapper().CreateMapper();

                DataSourceType dataSourceType = _iMapper.Map <DataSourceTypeDTO, DataSourceType>(dataSourceTypeDTO);

                IResult result = await _iDataSourceTypeService.UpdateAsync(dataSourceType);

                if (result.Success)
                {
                    return(Ok(result.Message));
                }
                return(BadRequest(result.Message));
            }
        }
コード例 #3
0
        public IActionResult Add(DataSourceTypeDTO dataSourceDTO)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState.GetErrorMessage()));
            }
            else
            {
                _iMapper = DataSourceTypeMapping.GetMapper().CreateMapper();
                DataSourceType dataSource = _iMapper.Map <DataSourceTypeDTO, DataSourceType>(dataSourceDTO);

                IResult result = _iDataSourceTypeService.Add(dataSource);

                if (result.Success)
                {
                    return(Ok(result.Message));
                }
                return(BadRequest(result.Message));
            }
        }
コード例 #4
0
        public async Task <IActionResult> AddAsync(DataSourceTypeDTO dataSourceTypeDTO)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState.GetErrorMessage()));
            }
            else
            {
                _iMapper = DataSourceTypeMapping.GetMapper().CreateMapper();

                DataSourceType dataSourceType = _iMapper.Map <DataSourceTypeDTO, DataSourceType>(dataSourceTypeDTO);

                IResult result = await _iDataSourceTypeService.AddAsync(dataSourceType);

                if (result.Success)
                {
                    return(Ok(result.Message));
                }
                return(BadRequest($"{result.Message} \n Try Again later can be either server error or user error "));
            }
        }