Beispiel #1
0
        public LoginResponse Login(LoginRequest request)
        {
            BusinessActions.LoginAction action = PolicyInjection.Create <BusinessActions.LoginAction>();

            BusinessEntities.LoginParameters parameters = LoginParametersTranslator.TranslateFromServiceToBusiness(request.LoginParameters);
            BusinessEntities.LoginResult     result     = action.Execute(parameters);

            LoginResponse response = new LoginResponse();

            response.LoginResult = LoginResultTranslator.TranslateFromBusinessToService(result);

            return(response);
        }
        public static Business.LoginResult TranslateFromServiceToBusiness(DataContracts.LoginResult serviceItem)
        {
            if (serviceItem == null)
            {
                return(null);
            }

            using (TranslationScope scope = new TranslationScope())
            {
                if (scope.Cache.Contains(serviceItem))
                {
                    return((Business.LoginResult)scope.Cache.Translate(serviceItem));
                }

                Business.LoginResult businessItem = new Business.LoginResult();
                scope.Cache.Add(serviceItem, businessItem);
                businessItem.Success      = serviceItem.Success;
                businessItem.ErrorMessage = serviceItem.ErrorMessage;
                return(businessItem);
            }
        }
        public static DataContracts.LoginResult TranslateFromBusinessToService(Business.LoginResult businessItem)
        {
            if (businessItem == null)
            {
                return(null);
            }

            using (TranslationScope scope = new TranslationScope())
            {
                if (scope.Cache.Contains(businessItem))
                {
                    return((DataContracts.LoginResult)scope.Cache.Translate(businessItem));
                }

                DataContracts.LoginResult serviceItem = new DataContracts.LoginResult();
                scope.Cache.Add(businessItem, serviceItem);

                serviceItem.Success      = businessItem.Success;
                serviceItem.ErrorMessage = businessItem.ErrorMessage;
                return(serviceItem);
            }
        }