public async Task <IActionResult> Get(int id) { try { _logger.LogDebug($"REST request to get {CONTROLLERENTITY} : {id}"); ApplicantGet applicantGet = await _applicantBusiness.GetById(id); return(StatusCode(201, applicantGet)); } catch (Exception exception) { _logger.LogError($"Error Occured in {Request.Path}: {exception.Message}"); return(BadRequest(exception.Message)); } }
public async Task <IActionResult> Post([FromBody] ApplicantAdd model) { try { _logger.LogDebug($"REST request to create new {CONTROLLERENTITY} : {JsonConvert.SerializeObject(model)}"); ApplicantGet applicantGet = await _applicantBusiness.Add(model); string getUrl = $"{Request.Host.ToString()}/{applicantGet.Id}"; return(StatusCode(201, new ResponseModel(applicantGet.Id, getUrl))); } catch (Exception exception) { _logger.LogError($"Error Occured in {Request.Path}: {exception.Message}"); return(StatusCode(500, exception.Message)); } }
public async Task <IActionResult> Put([FromBody] ApplicantUpdate model) { if (model.Id <= 0) { return(BadRequest($"Invalid parameter!")); } try { _logger.LogDebug($"REST request to edit {CONTROLLERENTITY} : {JsonConvert.SerializeObject(model)}"); ApplicantGet applicantGet = await _applicantBusiness.Update(model); string getUrl = $"{Request.Host.ToString()}/{applicantGet.Id}"; return(StatusCode(201, new ResponseModel(applicantGet.Id, getUrl))); } catch (Exception exception) { _logger.LogError($"Error Occured in {Request.Path}: {exception.Message}"); return(StatusCode(500, exception.Message)); } }