/// <summary> /// SetUserContext /// </summary> /// <param name="userContext"></param> protected void SetContext() { CommonManager commonManager = new CommonManager(); UserContextDC userContextDC= OperationContext.Current.IncomingMessageHeaders.GetHeader<UserContextDC>("ActiveUser", "s"); UserContext userContext = Mapper.Map<UserContextDC, UserContext>(userContextDC); RequestContextParameterDC requestContextParameterDC = null; // OperationContext.Current.IncomingMessageHeaders.GetHeader<RequestContextParameterDC>("RequestContext", "s"); RequestContextParameter requestContextParameter=null; if (requestContextParameterDC != null) requestContextParameter = Mapper.Map<RequestContextParameterDC, RequestContextParameter>(requestContextParameterDC); else requestContextParameter = new RequestContextParameter(); commonManager.SetUserContext(userContext,requestContextParameter); _coreValidationResourceManager = new ResourceManager(typeof(CoreValidationMessages)); }
/// <summary> /// SetUserContext /// </summary> /// <param name="userContext"></param> public void SetUserContext(UserContext userContext,RequestContextParameter requestContextParameter) { if (userContext.LanguageId == 0) userContext.LanguageId = eCollabroDbContext.Repository<lkpLanguage>().Query().Get().Where(op=>op.LanguageCode.Equals(userContext.Language)).FirstOrDefault().LanguageId; if (userContext.UserName != string.Empty) userContext.UserId = eCollabroDbContext.Repository<UserMembership>().Query().Get().Where(op=>op.UserName.Equals(userContext.UserName)).FirstOrDefault().UserId; if (RequestContext.Current.Get<UserContext>("UserContext") == null) RequestContext.Current.Add<UserContext>("UserContext",userContext); if (RequestContext.Current.Get<RequestContextParameter>("RequestParameter") == null) RequestContext.Current.Add("RequestParameter", requestContextParameter); }