public GetCodeResponse GetCodeById(long codeId) { var response = new GetCodeResponse(); try { ISession nhibernateSession = this.SessionFactory.GetCurrentSession(); var umaCode = nhibernateSession.LinqQuery<UmaCode>().FirstOrDefault(code => code.CodeId == codeId); if (umaCode == null) { response.OperationCallMessages.Add(string.Format(CultureInfo.InvariantCulture, "Code by Id {0} was not found in UMA", codeId.ToString("D", UmaConnCallContext.Current.ClientCulture))); } else { response.Code = CodeMapper.DatabaseToContract(umaCode); response.OperationCallStatus = CallStatus.Success; } } catch (Exception exc) { this.Logger.Error("UMA DB Query caused error", exc); response.OperationCallMessages.Add(exc.Message); } return response; }
public GetCodeResponse GetCodeByLabel(string codeLabel) { var response = new GetCodeResponse(); if (string.IsNullOrWhiteSpace(codeLabel)) { response.OperationCallMessages.Add("Parameter - Label for CODE is either null or empty"); return response; } string uppercaseLabel = codeLabel.ToUpperInvariant(); try { ISession nhibernateSession = this.SessionFactory.GetCurrentSession(); var umaCode = nhibernateSession.LinqQuery<UmaCode>().FirstOrDefault(code => code.Label == uppercaseLabel); if (umaCode == null) { response.OperationCallMessages.Add(string.Format(CultureInfo.InvariantCulture, "Code by label {0} was not found in UMA", uppercaseLabel)); } else { response.Code = CodeMapper.DatabaseToContract(umaCode); response.OperationCallStatus = CallStatus.Success; } } catch (Exception exc) { this.Logger.Error("UMA DB Query caused error", exc); response.OperationCallMessages.Add(exc.Message); } return response; }