Exemplo n.º 1
0
 public bool AddUserEmail(IExchangeUserInfo exchangeUserInfo, long currentUserPID)
 {
     try
     {
         ExEmail email = (ExEmail)exchangeUserInfo;
         using (UnitOfWork unitOfWork = new UnitOfWork())
         {
             UserDetailEmailRepository = unitOfWork.GetRepoInstance <UserDetailEmail>();
             EmailRepository           = unitOfWork.GetRepoInstance <Email>();
             IQueryable <UserDetailEmail> userDetailEmails = UserDetailEmailRepository.GetAllExpressions(x => x.UserDetailPID == currentUserPID && x.IsActive == true, null, null);
             if (userDetailEmails != null && userDetailEmails.Count <UserDetailEmail>() != 0)
             {
                 foreach (var item in userDetailEmails)
                 {
                     item.IsActive = false;
                 }
             }
             Email dbEmail = new Email();
             dbEmail.ID       = email.strEmail;
             dbEmail.IsActive = true;
             EmailRepository.Insert(dbEmail);
             UserDetailEmail udEmail = new UserDetailEmail();
             udEmail.IsActive      = true;
             udEmail.EmailPID      = dbEmail.EmailPid;
             udEmail.UserDetailPID = currentUserPID;
             UserDetailEmailRepository.Insert(udEmail);
             unitOfWork.SaveChanges();
         }
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
Exemplo n.º 2
0
        public void AddEmail(ExEmail exEmail)
        {
            UserManagement      userMgnt            = new UserManagement(exEmail, currentUserPID);
            UserManagementExten userManagementExten = new UserManagementExten();

            userMgnt.UpdateUserProfile(userManagementExten.AddUserEmail);
        }
Exemplo n.º 3
0
        public List <ExEmail> GetUserEmail(long currentUserPID)
        {
            List <ExEmail> lsExEmails = new List <ExEmail>();

            try
            {
                using (UnitOfWork unitOfWork = new UnitOfWork())
                {
                    UserDetailEmailRepository = unitOfWork.GetRepoInstance <UserDetailEmail>();
                    IQueryable <UserDetailEmail> userDetailEmails = UserDetailEmailRepository.GetAllExpressions(x => x.UserDetail.UserdetailPID == currentUserPID, null, null);
                    foreach (var item in userDetailEmails)
                    {
                        ExEmail exEmail = new ExEmail();
                        exEmail.strEmail = item.Email.ID;
                        lsExEmails.Add(exEmail);
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(lsExEmails);
        }
Exemplo n.º 4
0
        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);
            }
        }