Created
April 5, 2023 01:54
-
-
Save hendrasyp/0cb73166cba30171839b58495617eb6d to your computer and use it in GitHub Desktop.
Asynchronous Api NET6
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public async Task<IQueryable<object>> GetCountry() | |
{ | |
MSSQLDataAccess helper = new MSSQLDataAccess(_options); | |
List<SqlParam> tParams = new List<SqlParam>(); | |
tParams.Add(new SqlParam { ParamType = DataTypeConstant.STR, ParamValue = "" }); | |
string strSQL = helper.BuildQueryString(TSqlHelper.spName("STOREDPROCEDURE"), tParams); | |
IQueryable<object> result = helper.Read(strSQL); | |
return await Task.FromResult(result); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface ICountryService | |
{ | |
public Task<IQueryable<object>> GetCountry(); | |
public Task<IQueryable<object>> GetCountryByName(string name); | |
public void Save(Basic_Master_Area_Country_Update data, string userId); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public async Task<IActionResult> GetCountry_List([FromQuery] Country_Get_Request country) | |
{ | |
ResponseModels tResponse; | |
try | |
{ | |
IQueryable<object> result; | |
if (CommonHelper.StringIsEmpty(country.name)) | |
{ | |
result = await _countryService.GetCountry(); | |
} | |
else | |
{ | |
result = await _countryService.GetCountryByName(country.name); | |
} | |
tResponse = _responseService.GenerateResponseMessage(RestStatus.OK.ToString(), result); | |
} | |
catch (SqlException ex) | |
{ | |
tResponse = _responseService.GenerateResponseMessage(RestStatus.InternalServerError.ToString(), CommonHelper.GetGeneralException(ex)); | |
} | |
catch (Exception ex) | |
{ | |
tResponse = _responseService.GenerateResponseMessage(RestStatus.InternalServerError.ToString(), CommonHelper.GetGeneralException(ex)); | |
} | |
return Ok(tResponse); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment