Exemplo n.º 1
0
 public bool AddAddresses(IExchangeUserInfo exchangeUserInfo, long currentUserPID)
 {
     try
     {
         ExAddress address = (ExAddress)exchangeUserInfo;
         using (UnitOfWork unitOfWork = new UnitOfWork())
         {
             UserDetailAddressRepository = unitOfWork.GetRepoInstance <UserDetailAddress>();
             AddressRepository           = unitOfWork.GetRepoInstance <Address>();
             IQueryable <UserDetailAddress> userDetailAddresss = UserDetailAddressRepository.GetAllExpressions(x => x.UserDetailPID == currentUserPID && x.IsActive == true, null, null);
             if (userDetailAddresss != null && userDetailAddresss.Count <UserDetailAddress>() != 0)
             {
                 foreach (var item in userDetailAddresss)
                 {
                     item.IsActive = false;
                 }
             }
             Address dbAddress = new Address();
             dbAddress.Address1 = address.strAddress1;
             dbAddress.Address2 = address.strAddress2;
             dbAddress.Address3 = address.strAddress3;
             AddressRepository.Insert(dbAddress);
             UserDetailAddress udAddress = new UserDetailAddress();
             udAddress.IsActive      = true;
             udAddress.AddressPID    = dbAddress.AddressPID;
             udAddress.UserDetailPID = currentUserPID;
             UserDetailAddressRepository.Insert(udAddress);
             unitOfWork.SaveChanges();
         }
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
Exemplo n.º 2
0
        public void SaveNewUserDetails(NewUserRegistrationSupport NewUserDeatils)
        {
            GenericRepository <Phone>             PhoneRepository;
            GenericRepository <Email>             EmailRepository;
            GenericRepository <Address>           AddressRepository;
            GenericRepository <UserDetailAddress> UserDetailAddressRepository;
            GenericRepository <UserDetail>        UserDetailRepository;

            try
            {
                using (UnitOfWork unitOfWork = new UnitOfWork())
                {
                    try
                    {
                        #region Phone
                        PhoneRepository = unitOfWork.GetRepoInstance <Phone>();
                        Phone phone = new Phone();
                        phone.Number = NewUserDeatils.PhoneNumber;
                        PhoneRepository.Insert(phone);
                        #endregion

                        #region Email
                        EmailRepository = unitOfWork.GetRepoInstance <Email>();
                        Email email = new Email();
                        email.ID = NewUserDeatils.Email;
                        EmailRepository.Insert(email);
                        #endregion

                        #region Address
                        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

                        #region User Details
                        UserDetailRepository = unitOfWork.GetRepoInstance <UserDetail>();
                        UserDetail newUser = new UserDetail();
                        newUser.FirstName   = NewUserDeatils.FirstName;
                        newUser.LastName    = NewUserDeatils.LastName;
                        newUser.MiddleName  = NewUserDeatils.MiddleName;
                        newUser.DateofBirth = NewUserDeatils.Dob;
                        UDA.UserDetail      = newUser;
                        //newUser.UserDetailAddress.=UDA;
                        UserDetailRepository.Insert(newUser);
                        #endregion

                        unitOfWork.SaveChanges();
                    }
                    catch (Exception ex)
                    {
                        System.Diagnostics.Debug.WriteLine("System Stack :: " + ex.StackTrace + " System Exception Message :: " + ex.Message);
                    }
                }
            }
            catch (Exception ex)
            {
                LogHelper.WriteErrorLog(ex);
            }
        }