public bool AddUserPhone(IExchangeUserInfo exchangeUserInfo, long currentUserPID) { try { ExPhone phone = (ExPhone)exchangeUserInfo; using (UnitOfWork unitOfWork = new UnitOfWork()) { PhoneRepository = unitOfWork.GetRepoInstance <Phone>(); UserDetailPhoneRepository = unitOfWork.GetRepoInstance <UserDetailPhone>(); IQueryable <UserDetailPhone> userDetailPhones = UserDetailPhoneRepository.GetAllExpressions(x => x.UserDetailPID == currentUserPID && x.IsActive == true, null, null); if (userDetailPhones != null && userDetailPhones.Count <UserDetailPhone>() != 0) { foreach (var item in userDetailPhones) { item.IsActive = false; } } Phone dbphone = new Phone(); dbphone.Number = phone.strPhone; dbphone.IsActive = true; PhoneRepository.Insert(dbphone); UserDetailPhone udPhone = new UserDetailPhone(); udPhone.IsActive = true; udPhone.PhonePID = dbphone.Phonepid; udPhone.UserDetailPID = currentUserPID; UserDetailPhoneRepository.Insert(udPhone); unitOfWork.SaveChanges(); } return(true); } catch (Exception ex) { return(false); } }
public void AddPhone(ExPhone exPhone) { UserManagement userMgnt = new UserManagement(exPhone, currentUserPID); UserManagementExten userManagementExten = new UserManagementExten(); userMgnt.UpdateUserProfile(userManagementExten.AddUserPhone); }
public List <ExPhone> GetUserPhone(long currentUserPID) { List <ExPhone> lsExPhones = new List <ExPhone>(); try { using (UnitOfWork unitOfWork = new UnitOfWork()) { UserDetailPhoneRepository = unitOfWork.GetRepoInstance <UserDetailPhone>(); IQueryable <UserDetailPhone> userDetailPhones = UserDetailPhoneRepository.GetAllExpressions(x => x.UserDetail.UserdetailPID == currentUserPID, null, null); foreach (var item in userDetailPhones) { ExPhone exphone = new ExPhone(); exphone.strPhone = item.Phone.Number; lsExPhones.Add(exphone); } } } catch (Exception ex) { throw ex; } return(lsExPhones); }
public void SaveNewUserDetails(ref int UserCode, NewUserRegistrationSupport NewUserDeatils) { try { using (UnitOfWork unitOfWork = new UnitOfWork()) { try { DateTime tryDoB; var deDateTime = JsonConvert.DeserializeObject <JsonDate>(NewUserDeatils.strDob); tryDoB = new DateTime(deDateTime.year, deDateTime.month, deDateTime.day); string userGCode = GenerateUserCode(NewUserDeatils.strFirstName, tryDoB); if (ChechUserExistsbyCode(userGCode)) { UserCode = 0; return; } UserManagementExten userMgmtExt = new UserManagementExten(); #region User Details UserDetailRepository = unitOfWork.GetRepoInstance <UserDetail>(); UserDetail newUser = new UserDetail(); newUser.FirstName = NewUserDeatils.strFirstName; newUser.LastName = NewUserDeatils.strLastName; newUser.MiddleName = NewUserDeatils.strMiddleName; newUser.CreatedOn = DateTime.UtcNow; newUser.UpdatedOn = DateTime.UtcNow; newUser.DateofBirth = tryDoB; newUser.UserCode = userGCode; newUser.IsActive = true; UserDetailRepository.Insert(newUser); unitOfWork.SaveChanges(); UserCode = (int)newUser.UserdetailPID; #endregion #region Phone if (!string.IsNullOrEmpty(NewUserDeatils.PhoneNumber)) { ExPhone ePhone = new ExPhone(); ePhone.strPhone = NewUserDeatils.PhoneNumber; userMgmtExt.AddUserPhone(ePhone, newUser.UserdetailPID); } //PhoneRepository = unitOfWork.GetRepoInstance<Phone>(); //Phone phone = new Phone(); //phone.Number = NewUserDeatils.PhoneNumber; //PhoneRepository.Insert(phone); #endregion #region Email if (!string.IsNullOrEmpty(NewUserDeatils.Email)) { ExEmail eEmail = new ExEmail(); eEmail.strEmail = NewUserDeatils.Email; userMgmtExt.AddUserEmail(eEmail, newUser.UserdetailPID); } //EmailRepository = unitOfWork.GetRepoInstance<Email>(); //Email email = new Email(); //email.ID = NewUserDeatils.Email; //EmailRepository.Insert(email); #endregion #region Address if (!string.IsNullOrEmpty(NewUserDeatils.Address1)) { ExAddress eAddress = new ExAddress(); eAddress.strAddress1 = NewUserDeatils.Address1; eAddress.strAddress2 = NewUserDeatils.Address2; eAddress.strAddress3 = NewUserDeatils.Address3; userMgmtExt.AddAddresses(eAddress, newUser.UserdetailPID); } //AddressRepository = unitOfWork.GetRepoInstance<Address>(); //Address Add = new Address(); //Add.Address1 = NewUserDeatils.Address1; //Add.Address2 = NewUserDeatils.Address2; //Add.Address3 = NewUserDeatils.Address3; ////Add.Phone = phone; //Add.Email = email; //AddressRepository.Insert(Add); #endregion #region User Address Details //UserDetailAddressRepository = unitOfWork.GetRepoInstance<UserDetailAddress>(); //UserDetailAddress UDA = new UserDetailAddress(); //UDA.Address = Add; //UserDetailAddressRepository.Insert(UDA); #endregion } catch (Exception ex) { UserCode = 0; System.Diagnostics.Debug.WriteLine("System Stack :: " + ex.StackTrace + " System Exception Message :: " + ex.Message); } } } catch (Exception ex) { UserCode = 0; LogHelper.WriteErrorLog(ex); } }