public void Register(RegisterDataContract data)
        {
            if (data == null)
                throw new ArgumentNullException("data", "data cannot be null");

            IUser user = new UserService();
            int profileId = 0;
            int loginId = 0;
            try
            {
                profileId = user.RegisterProfile(data);
            }
            catch (Exception Ex)
            {
                ServiceFaultException SFEx = new ServiceFaultException(Ex.Message, "Register");
                throw new FaultException<ServiceFaultException>(SFEx, new FaultReason(SFEx.Description), new FaultCode("Register"));
            }
            finally
            {
                LoginDataContract loginDetail = new LoginDataContract(data.Username, data.Password);
                loginId = user.RegisterLogin(loginDetail, profileId);

                user.RegisterStatus(ChatState.INITIAL, loginId);

                OperationContext.Current.GetCallbackChannel<IServiceCallBack>().DoLoginCallBack(loginDetail);
            }
        }
Esempio n. 2
0
        public int RegisterProfile(RegisterDataContract registerData)
        {
            int profileId = 0;
            using (ProfileRepository profileRepo = new ProfileRepository(new ChatDBDataContext()))
            {
                List<tbl_ChatUserProfile> profiles = profileRepo.Get();
                if (!ServiceUtils.IsExist<tbl_ChatUserProfile>(profiles, registerData.EmailAddress))
                {
                    tbl_ChatUserProfile profile = new tbl_ChatUserProfile
                    {
                        Address = registerData.Address,
                        EmailAddess = registerData.EmailAddress,
                        FullName = registerData.FullName,
                        PhoneNumber = registerData.PhoneNumber
                    };
                    profileRepo.Create(profile);
                    profileRepo.Save();

                    profileId = profileRepo.Get(registerData.EmailAddress).id;
                }
                else
                    throw new Exception("Profile Exists");
            }
            return profileId;
        }