public BasicResponse <Member> GetMemberById(int memberId) { var response = new BasicResponse <Member>(); var member = _memberRepository.GetById(memberId); response.WasSuccessful = true; response.Object = member; return(response); }
public BasicResponse <Account> GetAccountById(int accountId, int memberId) { var response = new BasicResponse <Account>(); var member = _memberRepository.GetById(memberId); if (member != null && member.Accounts.Any()) { response.Object = member.Accounts.FirstOrDefault(x => x.Id == accountId); response.WasSuccessful = response.Object != null; } return(response); }
public async Task <IActionResult> Diff(string id) { //parameter validation - fails if null or empty if (id == null || id.Trim() == string.Empty) { return(BadRequest("Id field is required.")); } //retrieves object from database var json = await _jsonRepository.GetById(id); //fails if Id doesn't exist if (json == null) { return(BadRequest("There is no JSON stored under given ID.")); } //fails if LEFT or RIGHT sides are empty if (json.Left == null || json.Right == null) { return(BadRequest("Left and Right side are required to peform diff.")); } try { //Process differences and build response object var response = _diffService.ProcessDiff(json); return(Ok(response)); } catch (Exception ex) { //Logs and Returns bad request if fails when processing differences _logger.LogError($"Failed to process diff. Stack Trace: {ex.StackTrace}"); return(BadRequest($"Failed to process diff. Error Message: {ex.Message}")); } }