Untitled
unknown
plain_text
2 years ago
868 B
7
Indexable
IRepository.cs
public Task<string> GetDescription(string title);
Repository.cs
public async Task<string> GetDescription(string title){
try{
var blogDescrition = await _context.Blogs.Where(x=>x.BlogTitle==title)
.Select(x=>x.BlogDescription).FirstOrDefaultAsync();
if(blogDescrition==null){
return null;
}
else{
return blogDescrition;
}
}
catch(Exception ex){
return ex.Message;
}
}
BlogController.cs
[HttpGet("GetDetails")]
public async Task<ActionResult<string>> GetDetails([FromQuery]string title){
var b=await _blogRepository.GetDescription(title);
if(b==null){
return NotFound("Errorrrr");
}else{
return Ok(b);
}
}Editor is loading...
Leave a Comment