/// <summary> /// Initialize errors array. If the array is null, inializes it with StringToStringDictionary instance. Otherwise, does nothing. /// </summary> private void InitializeErrorArray() { if (Errors == null) { Errors = new StringToStringDictionary(); } }
/// <summary> /// Adds new exception to Exceptions property. /// </summary> /// <param name="exception">Exception to add.</param> public void Error(string key, string exception, T result) { if (this.Exceptions == null) { this.Exceptions = new StringToStringDictionary(); } this.Exceptions.Add(key, exception); IsSuccesful = false; SetResult(result); }
/// <summary> /// Clears errors /// </summary> public void ClearErrors() { if (this.Errors != null) { this.Errors.Clear(); this.Errors = null; } if (this.UserFriendlyErrorMesages != null) { this.UserFriendlyErrorMesages.Clear(); this.UserFriendlyErrorMesages = null; } }
public static ModalViewModel ForError(StringToStringDictionary errors, string title = null) { ModalViewModel model = PrepareForError(); foreach (KeyValuePair <string, string> error in errors) { model.Errors.Add(error.Key, error.Value); } if (!string.IsNullOrWhiteSpace(title)) { model.ErrorTitle = title; } return(model); }
/// <summary> /// Sets request result to ServiceRequestResult.Fail and add error if error is not null. /// </summary> /// <param name="errors"></param> public void Error(IEnumerable <string> errors, bool setFirendlyErrorMessages = false) { InitializeErrorArray(); SetResult(RequestStatus.Fail); if (errors != null && errors.Count() > 0) { errors.ToList().ForEach(error => this.Errors.Add(GetDictionaryKey(), error)); if (setFirendlyErrorMessages) { if (this.UserFriendlyErrorMesages == null) { this.UserFriendlyErrorMesages = new StringToStringDictionary(); } errors.ToList().ForEach(error => this.UserFriendlyErrorMesages.Add(GetDictionaryKey(), error)); } } }
/// <summary> /// Sets request result to ServiceRequestResult.Fail and add error if error is not null. /// </summary> /// <param name="errorKey"></param> /// <param name="errorMessage"></param> public void Error(string errorKey, string errorMessage, bool setFirendlyErrorMessages = false) { InitializeErrorArray(); SetResult(RequestStatus.Fail); if (errorKey == null) { this.Errors.Add(GetDictionaryKey(), errorMessage); } else { this.Errors.Add(errorKey, errorMessage); } if (setFirendlyErrorMessages) { if (this.UserFriendlyErrorMesages == null) { this.UserFriendlyErrorMesages = new StringToStringDictionary(); } this.UserFriendlyErrorMesages.Add(errorKey, errorMessage); } }
public string PrepareEmailTemplate(string emailTemplateHtml, string[] placeHolderCodes, StringToStringDictionary emailData) { if (placeHolderCodes != null && placeHolderCodes.Length > 0 && emailData != null && emailData.Count > 0) { foreach (string eachPlaceHolder in placeHolderCodes) { emailTemplateHtml = emailTemplateHtml.Replace(eachPlaceHolder, emailData[eachPlaceHolder]); } } return(emailTemplateHtml); }
public string PrepareEmailTemplate(string emailTemplateHtml, string placeHolderCodes, StringToStringDictionary emailData, string placeHoldersSeperator = "|") { string[] _placeHolders = placeHolderCodes.Split(new string[] { placeHoldersSeperator }, StringSplitOptions.RemoveEmptyEntries); string emailAsHtml = PrepareEmailTemplate(emailTemplateHtml, _placeHolders, emailData); return(emailAsHtml); }
public BusinessResultBase(bool isSuccessful) { Exceptions = new StringToStringDictionary(); IsSuccesful = false; }
public void Success() { this.Exceptions.Clear(); this.Exceptions = null; this.IsSuccesful = true; }
public ResponseBase() { this.Errors = new StringToStringDictionary(); this.Status = RequestStatus.Success; UserFriendlyErrorMesages = new StringToStringDictionary(); }