Last active
August 29, 2015 14:15
-
-
Save kjlape/ce33f212338f4a5f623d to your computer and use it in GitHub Desktop.
Example of refactoring at work.
This file contains hidden or 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
| // 0) | |
| private void UpdateErrorResponseLog(CommandResponseElement[] array, long id) | |
| { | |
| //Logging all errors and response messages returned to TOA_InboundAPI_Response_Errors table | |
| try{ | |
| foreach (CommandResponseElement value in array) | |
| { | |
| if(value.report != null){ | |
| foreach (ReportMessageElement rm in value.report) | |
| { | |
| if(rm != null){ | |
| TOADATA.InsertTOAErrorLog(id, rm.code, rm.description, rm.type); | |
| } | |
| } | |
| } | |
| } | |
| }catch(Exception e){ | |
| } | |
| } | |
| // 1) | |
| private void SetSessionTNWithAvailableDefaultTN() | |
| { | |
| WebProfile p = WebProfile.GetProfile(HttpContext.Current.User.Identity.Name, true); | |
| if (p.CurrentTN == "") | |
| { | |
| if (RadGrid1.Items.Count >= 1) | |
| { | |
| p.CurrentTN = RadGrid1.Items[0].Cells[2].Text.TrimEnd(); | |
| } | |
| else | |
| { | |
| p.CurrentTN = ""; | |
| } | |
| } | |
| else | |
| { | |
| //Purposely left blank. | |
| } | |
| p.Save(); | |
| } |
This file contains hidden or 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
| // 0) | |
| private void UpdateErrorResponseLog(CommandResponseElement[] array, long id) | |
| { | |
| try { | |
| foreach (ReportMessageElement rm in array | |
| .Where(x => x.report != null) | |
| .SelectMany(x => x.report) | |
| .Where(x => x!= null)) | |
| TOADATA.InsertTOAErrorLog(id, rm.code, rm.description, rm.type); | |
| } | |
| catch {} | |
| } | |
| // 1) | |
| private void SetSessionTNWithAvailableDefaultTN() | |
| { | |
| WebProfile p = WebProfile.GetProfile(HttpContext.Current.User.Identity.Name, true); | |
| if (string.IsNullOrEmpty(p.CurrentTN) && RadGrid1.Items.Count > 0) | |
| p.CurrentTN = RadGrid1.Items[0].Cells[2].Text.TrimEnd(); | |
| p.Save(); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment