예제 #1
0
        //GetAddressCard
        public AddressCard GetAddressCard(long addresscard_id, bool iscache)
        {
            DataCacheObject dco    = new DataCacheObject(DataCacheType.ACTIVITY, DataCacheRegions.USERS, "GETADDRESSCARD", new object[] { addresscard_id }, CachingExpirationTime.Hours_01);
            AddressCard     result = CacheRepository.Get(dco) as AddressCard;

            if (result != null && iscache)
            {
                return(result);
            }
            result = dataContext.spSelect_AddressCard(addresscard_id).SingleOrDefault();
            if (result != null)
            {
                dco.Data = result;
                CacheRepository.Add(dco);
            }
            return(result);
        }
예제 #2
0
        public static Address GetAddress(AddressCard ac)
        {
            Address addr = new Address();

            addr.Address_1  = ac.Address1;
            addr.Address_2  = ac.Address2;
            addr.City       = ac.City;
            addr.State      = ac.State;
            addr.State_ID   = ac.State_ID;
            addr.Country    = (ac.Country != null) ? ac.Country.Title : String.Empty;
            addr.Country_ID = ac.Country_ID;
            addr.Zip        = ac.Zip;
            addr.FirstName  = ac.FirstName;
            addr.LastName   = ac.LastName;
            addr.MiddleName = ac.MiddleName;
            addr.HomePhone  = ac.HomePhone;
            addr.WorkPhone  = ac.WorkPhone;
            return(addr);
        }
예제 #3
0
        //RefundingDeposits
        public bool RefundingDeposits(long user_id)
        {
            List <Deposit> deposits = dataContext.Deposits.Where(D => D.User_ID == user_id && !D.Event.IsCurrent && (!D.IsRefunded.HasValue || !D.IsRefunded.Value) && D.Amount > 0 && D.PaymentType_Id != (byte)Consts.PaymentType.WALKIN).ToList();

            if (deposits == null || deposits.Count() == 0)
            {
                return(false);
            }
            bool   result = false;
            string refundTransactionID = String.Empty;
            bool   res = true;

            foreach (Deposit deposit in deposits)
            {
                if (deposit.PaymentType_Id == (long)Consts.PaymentType.Paypal)
                {
                    result = PayPalRefund(deposit.Amount, "Refunding deposit", deposit.AuthCode, out refundTransactionID);
                }
                else
                {
                    result = CreditCardRefund(deposit.Amount, deposit.AuthCode, deposit.Num, "Refunding deposit", out refundTransactionID);
                }
                if (result)
                {
                    deposit.IsRefunded            = true;
                    deposit.RefundedTransactionID = refundTransactionID;
                    deposit.RefundedDate          = DateTime.Now;
                    SubmitChanges();
                    IUserRepository userRepository = new UserRepository(dataContext, CacheRepository);
                    User            user           = userRepository.GetUser(deposit.User_ID, true);
                    AddressCard     ac             = userRepository.GetAddressCard(user.Billing_AddressCard_ID.GetValueOrDefault(-1), true);
                    Mail.SendRefundingDepositConfirmation(ac.FirstName, ac.LastName, user.Email, deposit.Amount, deposit.AuthCode, deposit.RefundedTransactionID, deposit.DatePaid.Value.ToString(), deposit.PaymentType, HttpContext.Current.Server.MapPath(@"~\Templates\Mail\RefundingDeposit.txt"), AppHelper.GetSiteUrl());
                }
                else
                {
                    Logger.LogWarning(string.Format("Refunding deposit failed. User:{0} | Type: {1} | TransactionID:{2}", deposit.User.Login, deposit.PaymentType, deposit.AuthCode));
                    res = false;
                }
            }
            return(res);
        }
예제 #4
0
 //SubscribeRegisterUser
 public bool SubscribeRegisterUser(User u)
 {
     try
     {
         if (u == null)
         {
             throw new Exception("The user doesn't exist");
         }
         OuterSubscription os = dataContext.OuterSubscriptions.SingleOrDefault(OU => OU.Email == u.Email);
         if (os != null)
         {
             os.IsActive                  = true;
             os.IsRecievingUpdates        = !u.NotRecieveNewsUpdates;
             os.IsRecievingWeeklySpecials = !u.NotRecieveWeeklySpecials;
             SubmitChanges();
             return(false);
         }
         AddressCard acB = GetAddressCard(u.Billing_AddressCard_ID.GetValueOrDefault(-1), true);
         os                           = new OuterSubscription();
         os.Country                   = acB.Country.Title;
         os.Email                     = u.Email;
         os.EmailConfirm              = u.Email;
         os.IsActive                  = true;
         os.IPAddress                 = Consts.UsersIPAddress;
         os.IsRecievingUpdates        = !u.NotRecieveNewsUpdates;
         os.IsRecievingWeeklySpecials = !u.NotRecieveWeeklySpecials;
         os.FirstName                 = acB.FirstName;
         os.LastName                  = acB.LastName;
         os.State                     = acB.State;
         dataContext.OuterSubscriptions.InsertOnSubmit(os);
         SubmitChanges();
     }
     catch (Exception ex)
     {
         Logger.LogException("[user_id=" + u != null?u.ID.ToString():"null" + "]", ex);
         return(false);
     }
     return(true);
 }
예제 #5
0
        //UpdateUser
        public bool UpdateUser(UserRegistration info)
        {
            bool newUser = info.ID < 1;
            User user    = (!newUser) ? GetUser(info.ID) : new User();

            try
            {
                using (TransactionScope ts = new TransactionScope())
                {
                    if (newUser)
                    {
                        dataContext.Users.InsertOnSubmit(user);
                    }
                    user.Login             = info.Login;
                    user.Password          = info.Password;
                    user.UserType_ID       = info.UserType;
                    user.UserStatus_ID     = info.UserStatus;
                    user.CommissionRate_ID = info.CommissionRate;
                    user.Email             = info.Email;
                    user.DateRegistered    = (newUser) ? DateTime.Now : user.DateRegistered;
                    user.IsConfirmed       = info.IsConfirmed;
                    user.IsModifyed        = info.IsModifyed;
                    user.DayPhone          = info.DayPhone;
                    user.EveningPhone      = info.EveningPhone;
                    user.MobilePhone       = info.MobilePhone;
                    user.Fax                        = info.Fax;
                    user.TaxpayerID                 = info.Tax;
                    user.FailedAttempts             = info.FaildAttempts;
                    user.RecieveWeeklySpecials      = info.RecieveWeeklySpecials;
                    user.RecieveNewsUpdates         = info.RecieveNewsUpdates;
                    user.IsRecievingBidConfirmation = info.RecieveBidConfirmation;
                    user.IsRecievingOutBidNotice    = info.RecieveOutBidNotice;
                    user.IsRecievingLotClosedNotice = info.RecieveLotClosedNotice;
                    user.IsRecievingLotSoldNotice   = info.RecieveLotSoldNotice;
                    user.EbayID                     = info.eBayBidderID;
                    user.EbayFeedback               = info.eBayFeedback;
                    user.Notes                      = info.Notes;
                    user.IsCatalog                  = info.IsCatalog;
                    user.IsPostCards                = info.IsPostCards;

                    AddressCard ac = (newUser || user.AddressCard_Billing == null) ? new AddressCard() : user.AddressCard_Billing;
                    ac.FirstName          = info.BillingFirstName;
                    ac.MiddleName         = info.BillingMiddleName;
                    ac.LastName           = info.BillingLastName;
                    ac.Company            = info.BillingCompany;
                    ac.Address1           = info.BillingAddress1;
                    ac.Address2           = info.BillingAddress2;
                    ac.City               = info.BillingCity;
                    ac.State              = info.BillingState;
                    ac.State_ID           = info.BillingState_ID;
                    ac.Zip                = info.BillingZip;
                    ac.Country_ID         = info.BillingCountry;
                    ac.InternationalState = info.BillingInternationalState;
                    if (newUser || user.AddressCard_Billing == null)
                    {
                        dataContext.AddressCards.InsertOnSubmit(ac);
                        user.AddressCard_Billing = ac;
                    }

                    user.BillingLikeShipping = info.BillingLikeShipping;

                    ac                    = (newUser || user.AddressCard_Shipping == null) ? new AddressCard() : user.AddressCard_Shipping;
                    ac.FirstName          = (info.BillingLikeShipping) ? info.BillingFirstName : info.ShippingFirstName;
                    ac.MiddleName         = (info.BillingLikeShipping) ? info.BillingMiddleName : info.ShippingMiddleName;
                    ac.LastName           = (info.BillingLikeShipping) ? info.BillingLastName : info.ShippingLastName;
                    ac.Company            = (info.BillingLikeShipping) ? info.BillingCompany : info.ShippingCompany;
                    ac.Address1           = (info.BillingLikeShipping) ? info.BillingAddress1 : info.ShippingAddress1;
                    ac.Address2           = (info.BillingLikeShipping) ? info.BillingAddress2 : info.ShippingAddress2;
                    ac.City               = (info.BillingLikeShipping) ? info.BillingCity : info.ShippingCity;
                    ac.State              = (info.BillingLikeShipping) ? info.BillingState : info.ShippingState;
                    ac.State_ID           = (info.BillingLikeShipping) ? info.BillingState_ID : info.ShippingState_ID;
                    ac.Zip                = (info.BillingLikeShipping) ? info.BillingZip : info.ShippingZip;
                    ac.Country_ID         = (info.BillingLikeShipping) ? info.BillingCountry : info.ShippingCountry;
                    ac.InternationalState = (info.BillingLikeShipping) ? info.BillingInternationalState : info.ShippingInternationalState;
                    if (newUser || user.AddressCard_Shipping == null)
                    {
                        dataContext.AddressCards.InsertOnSubmit(ac);
                        user.AddressCard_Shipping = ac;
                    }

                    UserReference ur = (newUser || user.UserReference_1 == null) ? new UserReference() : user.UserReference_1;
                    ur.AuctionHouse  = info.AuctionHouse1;
                    ur.PhoneNumber   = info.PhoneNumber1;
                    ur.LastBidPlaced = info.LastBidDate1;
                    if (newUser || user.UserReference_1 == null)
                    {
                        dataContext.UserReferences.InsertOnSubmit(ur);
                        user.UserReference_1 = ur;
                    }

                    ur = (newUser || user.UserReference_2 == null) ? new UserReference() : user.UserReference_2;
                    ur.AuctionHouse  = info.AuctionHouse2;
                    ur.PhoneNumber   = info.PhoneNumber2;
                    ur.LastBidPlaced = info.LastBidDate2;
                    if (newUser || user.UserReference_2 == null)
                    {
                        dataContext.UserReferences.InsertOnSubmit(ur);
                        user.UserReference_2 = ur;
                    }

                    GeneralRepository.SubmitChanges(dataContext);
                    ts.Complete();
                    info.ID = user.ID;
                }
            }
            catch (ChangeConflictException cce)
            {
                Logger.LogException(cce);
                throw cce;
            }
            catch (Exception ex)
            {
                Logger.LogException(ex);
                throw ex;
            }
            return(true);
        }
예제 #6
0
 private string GetFullAddress(AddressCard ac, string separator)
 {
     return((ac == null) ? "---" : String.Format("Addr1: {0}{7}Addr2: {1}{7}City: {2}{7}State: {3}{7}Country: {4}{7}Zip: {5}{7}Company: {6}", ac.Address1, ac.Address2, ac.City, ac.State, ac.Country.Title, ac.Zip, ac.Company, separator));
 }
예제 #7
0
 private string GetFullPhone(AddressCard ac)
 {
     return((ac == null) ? "---" : String.Format("{0}{1}{2}", (!String.IsNullOrEmpty(ac.HomePhone) ? "H: " + ac.HomePhone : ""), (!String.IsNullOrEmpty(ac.HomePhone) && !String.IsNullOrEmpty(ac.WorkPhone)) ? ";  " : String.Empty, (!String.IsNullOrEmpty(ac.WorkPhone) ? "W: " + ac.WorkPhone : "")));
 }
예제 #8
0
        //AddUser
        public User AddUser(RegisterInfo info)
        {
            User user = new User();

            try
            {
                dataContext.Users.InsertOnSubmit(user);
                user.Login            = info.Login;
                user.Email            = info.Email;
                user.ConfirmationCode = Guid.NewGuid().ToString().Replace("-", "");
                user.Password         = info.Password;
                user.DateRegistered   = DateTime.Now;
                user.UserType         = (byte)Consts.UserTypes.Buyer;
                user.IsConfirmed      = false;
                user.Fax = info.Fax;
                user.BillingLikeShipping = info.BillingLikeShipping;
                user.Status                     = (byte)Consts.UserStatus.Pending;
                user.MobilePhone                = info.MobilePhone;
                user.TaxpayerID                 = info.TaxpayerID;
                user.EbayID                     = info.EbayID;
                user.EbayFeedback               = info.EbayFeedback;
                user.DayPhone                   = info.DayPhone;
                user.EveningPhone               = info.EveningPhone;
                user.IsModifyed                 = true;
                user.IsRecievingOutBidNotice    = info.RecievingOutBidNotice;
                user.CommissionRate_ID          = Consts.DefaultCommissionRate;
                user.RecieveNewsUpdates         = true;
                user.RecieveWeeklySpecials      = true;
                user.IsRecievingBidConfirmation = true;
                user.IsRecievingLotClosedNotice = true;
                user.IsRecievingLotSoldNotice   = true;

                IDifferentRepository diff = new DifferentRepository(dataContext, CacheRepository);
                State BillingState        = diff.GetStateByCode(info.BillingState);
                State ShippingState;
                long  state1 = (BillingState == null) ? 0 : BillingState.ID;;
                long  state2;
                if (!info.BillingLikeShipping)
                {
                    ShippingState = diff.GetStateByCode(info.ShippingState);
                    state2        = (ShippingState == null) ? 0 : ShippingState.ID;
                }
                else
                {
                    state2 = state1;
                }

                AddressCard ac = new AddressCard();
                dataContext.AddressCards.InsertOnSubmit(ac);
                ac.FirstName             = info.BillingFirstName;
                ac.LastName              = info.BillingLastName;
                ac.MiddleName            = info.BillingMIName;
                ac.Address1              = info.BillingAddress1;
                ac.Address2              = info.BillingAddress2;
                ac.State                 = String.IsNullOrEmpty(info.BillingState) ? String.Empty : info.BillingState;
                ac.City                  = info.BillingCity;
                ac.Zip                   = info.BillingZip;
                ac.Country_ID            = info.BillingCountry;
                ac.Company               = info.BillingCompany;
                ac.InternationalState    = info.BillingInternationalState;
                ac.HomePhone             = ac.WorkPhone = info.BillingPhone;
                ac.State_ID              = state1;
                user.AddressCard_Billing = ac;

                ac = new AddressCard();
                dataContext.AddressCards.InsertOnSubmit(ac);
                ac.FirstName              = info.BillingFirstName;
                ac.LastName               = info.BillingLastName;
                ac.MiddleName             = info.BillingMIName;
                ac.Address1               = (user.BillingLikeShipping) ? info.BillingAddress1 : info.ShippingAddress1;
                ac.Address2               = (user.BillingLikeShipping) ? info.BillingAddress2 : info.ShippingAddress2;
                ac.State                  = (user.BillingLikeShipping) ? info.BillingState : info.ShippingState;
                ac.City                   = (user.BillingLikeShipping) ? info.BillingCity : info.ShippingCity;
                ac.Zip                    = (user.BillingLikeShipping) ? info.BillingZip : info.ShippingZip;
                ac.Country_ID             = (user.BillingLikeShipping) ? info.BillingCountry : info.ShippingCountry;
                ac.InternationalState     = (user.BillingLikeShipping) ? info.BillingInternationalState : info.ShippingInternationalState;
                ac.State_ID               = (user.BillingLikeShipping) ? state1 : state2;
                ac.HomePhone              = ac.WorkPhone = (user.BillingLikeShipping) ? info.BillingPhone : info.ShippingPhone;
                ac.State_ID               = (user.BillingLikeShipping) ? state1 : state2;
                user.AddressCard_Shipping = ac;

                UserReference ur = new UserReference();
                dataContext.UserReferences.InsertOnSubmit(ur);
                ur.AuctionHouse    = info.Reference1AuctionHouse;
                ur.PhoneNumber     = info.Reference1PhoneNumber;
                ur.LastBidPlaced   = info.Reference1LastBidPlaced;
                user.UserReference = ur;

                ur = new UserReference();
                dataContext.UserReferences.InsertOnSubmit(ur);
                ur.AuctionHouse     = info.Reference2AuctionHouse;
                ur.PhoneNumber      = info.Reference2PhoneNumber;
                ur.LastBidPlaced    = info.Reference2LastBidPlaced;
                user.UserReference1 = ur;

                SubmitChanges();
                RemoveUserFromCache(user.ID, user.Email);
            }
            catch (Exception ex)
            {
                Logger.LogException(ex);
            }
            return(user);
        }
예제 #9
0
        //UpdateUser
        public User UpdateUser(RegisterInfo info)
        {
            User usr = GetUser(info.ID, false);

            try
            {
                if (usr == null)
                {
                    usr = new User();
                    dataContext.Users.InsertOnSubmit(usr);
                }

                usr.Login                 = info.Login;
                usr.Email                 = info.Email;
                usr.Password              = info.Password;
                usr.RecieveNewsUpdates    = info.RecieveNewsUpdates;
                usr.RecieveWeeklySpecials = info.RecieveWeeklySpecials;
                usr.Fax = info.Fax;
                usr.BillingLikeShipping = info.BillingLikeShipping;
                usr.MobilePhone         = info.MobilePhone;
                usr.TaxpayerID          = info.TaxpayerID;
                usr.EbayID       = info.EbayID;
                usr.EbayFeedback = info.EbayFeedback;
                usr.DayPhone     = info.DayPhone;
                usr.EveningPhone = info.EveningPhone;
                usr.IsModifyed   = true;

                State BillingState, ShippingState;
                long  state1, state2;

                IDifferentRepository diff = new DifferentRepository(dataContext, CacheRepository);
                BillingState = (!String.IsNullOrEmpty(info.BillingState)) ? diff.GetStateByCode(info.BillingState.ToLower()) : null;
                state1       = (BillingState == null) ? 0 : BillingState.ID;
                if (!info.BillingLikeShipping)
                {
                    ShippingState = (!String.IsNullOrEmpty(info.ShippingState)) ? diff.GetStateByCode(info.ShippingState.ToLower()) : null;
                    state2        = (ShippingState == null) ? 0 : ShippingState.ID;
                }
                else
                {
                    state2 = state1;
                }

                IAddressCard ac1 = GetAddressCard(usr.Billing_AddressCard_ID.GetValueOrDefault(-1), false);
                if (ac1 == null)
                {
                    ac1 = new AddressCard();
                    dataContext.AddressCards.InsertOnSubmit(ac1 as AddressCard);
                    usr.AddressCard_Billing = ac1 as AddressCard;
                }
                ac1.FirstName          = info.BillingFirstName;
                ac1.LastName           = info.BillingLastName;
                ac1.MiddleName         = info.BillingMIName;
                ac1.Address1           = info.BillingAddress1;
                ac1.Address2           = info.BillingAddress2;
                ac1.City               = info.BillingCity;
                ac1.State              = String.IsNullOrEmpty(info.BillingState) ? String.Empty : info.BillingState;
                ac1.Zip                = info.BillingZip;
                ac1.Country_ID         = info.BillingCountry;
                ac1.Company            = info.BillingCompany;
                ac1.InternationalState = info.BillingInternationalState;
                ac1.HomePhone          = ac1.WorkPhone = info.BillingPhone;
                ac1.State_ID           = state1;

                IAddressCard ac = usr.Shipping_AddressCard_ID.HasValue ? GetAddressCard(usr.Shipping_AddressCard_ID.GetValueOrDefault(-1), false) : GetAddressCard(usr.Billing_AddressCard_ID.GetValueOrDefault(-1), false);
                if (ac == null)
                {
                    ac = new AddressCard();
                    dataContext.AddressCards.InsertOnSubmit(ac as AddressCard);
                    usr.AddressCard_Shipping = ac as AddressCard;
                }
                ac.FirstName          = info.BillingFirstName;
                ac.LastName           = info.BillingLastName;
                ac.MiddleName         = info.BillingMIName;
                ac.Address1           = (usr.BillingLikeShipping) ? info.BillingAddress1 : info.ShippingAddress1;
                ac.Address2           = (usr.BillingLikeShipping) ? info.BillingAddress2 : info.ShippingAddress2;
                ac.City               = (usr.BillingLikeShipping) ? info.BillingCity : info.ShippingCity;
                ac.State              = (usr.BillingLikeShipping) ? info.BillingState : info.ShippingState;
                ac.State              = String.IsNullOrEmpty(ac.State)?String.Empty:ac.State;
                ac.InternationalState = (usr.BillingLikeShipping) ? info.BillingInternationalState : info.ShippingInternationalState;
                ac.Zip        = (usr.BillingLikeShipping) ? info.BillingZip : info.ShippingZip;
                ac.Country_ID = (usr.BillingLikeShipping) ? info.BillingCountry : info.ShippingCountry;
                ac.HomePhone  = ac.WorkPhone = (usr.BillingLikeShipping) ? info.BillingPhone : info.ShippingPhone;
                ac.State_ID   = (usr.BillingLikeShipping) ? state1 : state2;

                SubmitChanges();

                RemoveUserFromCache(usr.ID, usr.Email);
            }
            catch (Exception ex)
            {
                Logger.LogException(ex);
                throw ex;
            }
            return(usr);
        }
예제 #10
0
        //UpdateUser
        public User UpdateUser(RegisterInfo info)
        {
            User usr = GetUser(info.ID, false);

            try
            {
                if (usr == null)
                {
                    throw new Exception("The user doesn't exist");
                }
                if (usr.Email != info.Email)
                {
                    usr.ConfirmationCode = Guid.NewGuid().ToString().Replace("-", "");
                }
                usr.Email    = info.Email;
                usr.Password = info.Password;
                usr.NotRecieveNewsUpdates    = !info.RecieveNewsUpdates;
                usr.NotRecieveWeeklySpecials = !info.RecieveWeeklySpecials;
                usr.Reference           = info.Reference;
                usr.BillingLikeShipping = info.BillingLikeShipping;
                usr.IsModifyed          = true;
                usr.NotPasswordReset    = false;

                info.NotPasswordReset = false;
                info.IsModifyed       = true;

                ICountryRepository repCountry = new CountryRepository(dataContext, CacheRepository);
                State BillingState            = repCountry.GetStateByCode(info.BillingState);
                State ShippingState;
                long  state1 = (BillingState == null) ? 0 : BillingState.ID;
                long  state2;
                if (!info.BillingLikeShipping)
                {
                    ShippingState = repCountry.GetStateByCode(info.ShippingState.ToLower());
                    state2        = (ShippingState == null) ? 0 : ShippingState.ID;
                }
                else
                {
                    state2 = state1;
                }

                IAddressCard acB = GetAddressCard(usr.Billing_AddressCard_ID.GetValueOrDefault(-1), false);
                if (acB == null)
                {
                    acB = new AddressCard();
                    dataContext.AddressCards.InsertOnSubmit(acB as AddressCard);
                    usr.AddressCard_Billing = acB as AddressCard;
                }
                acB.FirstName  = info.BillingFirstName;
                acB.LastName   = info.BillingLastName;
                acB.MiddleName = info.BillingMIName;
                acB.Address1   = info.BillingAddress1;
                acB.Address2   = info.BillingAddress2;
                acB.City       = info.BillingCity;
                acB.State      = String.IsNullOrEmpty(info.BillingState) ? String.Empty : info.BillingState;
                acB.Zip        = info.BillingZip;
                acB.Country_ID = info.BillingCountry;
                acB.HomePhone  = info.BillingPhone;
                acB.WorkPhone  = info.BillingWorkPhone;
                acB.State_ID   = state1;
                acB.Fax        = info.BillingFax;

                IAddressCard acS = usr.Shipping_AddressCard_ID.HasValue ? GetAddressCard(usr.Shipping_AddressCard_ID.GetValueOrDefault(-1), false) : GetAddressCard(usr.Billing_AddressCard_ID.GetValueOrDefault(-1), false);
                if (acS == null)
                {
                    acS = new AddressCard();
                    dataContext.AddressCards.InsertOnSubmit(acS as AddressCard);
                    usr.AddressCard_Shipping = acS as AddressCard;
                }
                acS.FirstName  = (usr.BillingLikeShipping) ?info.BillingFirstName : info.ShippingFirstName;
                acS.LastName   = (usr.BillingLikeShipping) ?info.BillingLastName : info.ShippingLastName;
                acS.MiddleName = (usr.BillingLikeShipping) ?info.BillingMIName : info.ShippingMIName;
                acS.Address1   = (usr.BillingLikeShipping) ? info.BillingAddress1 : info.ShippingAddress1;
                acS.Address2   = (usr.BillingLikeShipping) ? info.BillingAddress2 : info.ShippingAddress2;
                acS.City       = (usr.BillingLikeShipping) ? info.BillingCity : info.ShippingCity;
                acS.State      = (usr.BillingLikeShipping) ? info.BillingState : info.ShippingState;
                acS.State      = String.IsNullOrEmpty(acS.State) ? String.Empty : acS.State;
                acS.Zip        = (usr.BillingLikeShipping) ? info.BillingZip : info.ShippingZip;
                acS.Country_ID = (usr.BillingLikeShipping) ? info.BillingCountry : info.ShippingCountry;
                acS.HomePhone  = (usr.BillingLikeShipping) ? info.BillingPhone : info.ShippingPhone;
                acS.WorkPhone  = (usr.BillingLikeShipping) ? info.BillingWorkPhone : info.ShippingWorkPhone;
                acS.State_ID   = (usr.BillingLikeShipping) ? state1 : state2;
                acB.Fax        = (usr.BillingLikeShipping) ? info.BillingFax : info.ShippingFax;

                SubmitChanges();
                UpdateUserCache(usr);

                DataCacheObject dco = new DataCacheObject(DataCacheType.ACTIVITY, DataCacheRegions.USERS, "GETREGISTERINFO", new object[] { usr.ID }, CachingExpirationTime.Minutes_30, info);
                CacheRepository.Put(dco);
                dco.Method = "GETADDRESSCARD";
                dco.Params = new object[] { acB.ID };
                dco.Data   = acB;
                CacheRepository.Put(dco);
                dco.Params = new object[] { acS.ID };
                dco.Data   = acS;
                CacheRepository.Put(dco);
                //CacheRepository.Update(CacheDataKeys.USER_GETREGISTERINFO, info, new object[] { usr.ID });
                //CacheRepository.Update(CacheDataKeys.USER_GETADDRESSCARD, acB, new object[] { acB.ID });
                //CacheRepository.Update(CacheDataKeys.USER_GETADDRESSCARD, acS, new object[] { acS.ID });
            }
            catch (Exception ex)
            {
                Logger.LogException("[registerinfo>login: "******"]", ex);
                return(null);
            }
            return(usr);
        }
예제 #11
0
        //AddUser
        public User AddUser(RegisterInfo info)
        {
            User user = new User();

            try
            {
                ICountryRepository repCountry = new CountryRepository(dataContext, CacheRepository);

                State BillingState = repCountry.GetStateByCode(info.BillingState);
                State ShippingState;
                long  state1 = (BillingState == null) ? 0 : BillingState.ID;
                long  state2;
                if (!info.BillingLikeShipping)
                {
                    ShippingState = repCountry.GetStateByCode(info.ShippingState.ToLower());
                    state2        = (ShippingState == null) ? 0 : ShippingState.ID;
                }
                else
                {
                    state2 = state1;
                }

                AddressCard BillingCard = new AddressCard();
                dataContext.AddressCards.InsertOnSubmit(BillingCard);
                BillingCard.Address1   = info.BillingAddress1;
                BillingCard.Address2   = info.BillingAddress2;
                BillingCard.Zip        = info.BillingZip;
                BillingCard.City       = info.BillingCity;
                BillingCard.FirstName  = info.BillingFirstName;
                BillingCard.LastName   = info.BillingLastName;
                BillingCard.MiddleName = info.BillingMIName;
                BillingCard.State      = info.BillingState;
                BillingCard.Country_ID = info.BillingCountry;
                BillingCard.HomePhone  = info.BillingPhone;
                BillingCard.WorkPhone  = info.BillingWorkPhone;
                BillingCard.Fax        = info.BillingFax;
                BillingCard.State_ID   = state1;

                AddressCard ShippingCard = new AddressCard();
                dataContext.AddressCards.InsertOnSubmit(ShippingCard);
                ShippingCard.FirstName  = (info.BillingLikeShipping) ? info.BillingFirstName : info.ShippingFirstName;
                ShippingCard.LastName   = (info.BillingLikeShipping) ? info.BillingLastName : info.ShippingLastName;
                ShippingCard.MiddleName = (info.BillingLikeShipping) ? info.BillingMIName : info.ShippingMIName;
                ShippingCard.Address1   = (info.BillingLikeShipping) ? info.BillingAddress1 : info.ShippingAddress1;
                ShippingCard.Address2   = (info.BillingLikeShipping) ? info.BillingAddress2 : info.ShippingAddress2;
                ShippingCard.City       = (info.BillingLikeShipping) ? info.BillingCity : info.ShippingCity;
                ShippingCard.State      = (info.BillingLikeShipping) ? info.BillingState : info.ShippingState;
                ShippingCard.Country_ID = (info.BillingLikeShipping) ? info.BillingCountry : info.ShippingCountry;
                ShippingCard.HomePhone  = (info.BillingLikeShipping) ? info.BillingPhone : info.ShippingPhone;
                ShippingCard.WorkPhone  = (info.BillingLikeShipping) ? info.BillingWorkPhone : info.ShippingWorkPhone;
                ShippingCard.Fax        = (info.BillingLikeShipping) ? info.BillingFax : info.ShippingFax;
                ShippingCard.Zip        = (info.BillingLikeShipping) ? info.BillingZip : info.ShippingZip;
                ShippingCard.State_ID   = (info.BillingLikeShipping) ? state1 : state2;

                dataContext.Users.InsertOnSubmit(user);
                user.Login                       = info.Login.Trim();
                user.Email                       = info.Email;
                user.ConfirmationCode            = Guid.NewGuid().ToString().Replace("-", "");
                user.Password                    = info.Password;
                user.NotRecieveNewsUpdates       = !info.RecieveNewsUpdates;
                user.NotRecieveWeeklySpecials    = !info.RecieveWeeklySpecials;
                user.DateIN                      = DateTime.Now;
                user.UserType                    = (byte)Consts.UserTypes.Buyer;
                user.IsConfirmed                 = false;
                user.Reference                   = info.Reference;
                user.BillingLikeShipping         = info.BillingLikeShipping;
                user.Status                      = (byte)Consts.UserStatus.Pending;
                user.Notes                       = string.Empty;
                user.IsModifyed                  = true;
                user.CommRate_ID                 = Consts.DefaultCommissionRate;
                user.NotRecievingBidConfirmation = user.NotRecievingLotClosedNotice = user.NotRecievingLotSoldNotice = user.NotRecievingOutBidNotice = false;

                user.AddressCard_Billing  = BillingCard;
                user.AddressCard_Shipping = ShippingCard;

                SubmitChanges();
            }
            catch (Exception ex)
            {
                Logger.LogException(ex);
                user = null;
            }
            return(user);
        }
예제 #12
0
        //GetRegisterInfo
        public RegisterInfo GetRegisterInfo(long user_id)
        {
            DataCacheObject dco  = new DataCacheObject(DataCacheType.ACTIVITY, DataCacheRegions.USERS, "GETREGISTERINFO", new object[] { user_id }, CachingExpirationTime.Minutes_30);
            RegisterInfo    info = CacheRepository.Get(dco) as RegisterInfo;

            if (info != null)
            {
                return(info);
            }
            info = new RegisterInfo();
            try
            {
                User user = GetUser(user_id, true);
                if (user == null)
                {
                    throw new Exception("The user doesn't exist");
                }

                info.ID                    = user.ID;
                info.Login                 = user.Login;
                info.Email                 = user.Email;
                info.Password              = user.Password;
                info.ConfirmPassword       = user.Password;
                info.ConfirmEmail          = user.Email;
                info.RecieveNewsUpdates    = !user.NotRecieveNewsUpdates;
                info.RecieveWeeklySpecials = !user.NotRecieveWeeklySpecials;
                info.Reference             = user.Reference;
                info.BillingLikeShipping   = user.BillingLikeShipping;
                info.NotPasswordReset      = user.NotPasswordReset;
                info.IsModifyed            = user.IsModifyed;
                info.IsConsignorShip       = user.IsConsignorShip;

                AddressCard BillingCard = user.Billing_AddressCard_ID.GetValueOrDefault(0) > 0 ? GetAddressCard(user.Billing_AddressCard_ID.GetValueOrDefault(-1), true) : new AddressCard();
                info.BillingFirstName = BillingCard.FirstName;
                info.BillingLastName  = BillingCard.LastName;
                info.BillingMIName    = BillingCard.MiddleName;
                info.BillingFax       = BillingCard.Fax;
                info.BillingAddress1  = BillingCard.Address1;
                info.BillingAddress2  = BillingCard.Address2;
                info.BillingCity      = BillingCard.City;
                info.BillingZip       = BillingCard.Zip;
                info.BillingState     = BillingCard.State;
                info.BillingPhone     = BillingCard.HomePhone;
                info.BillingWorkPhone = BillingCard.WorkPhone;
                info.BillingCountry   = BillingCard.Country_ID;

                AddressCard ShippingCard = user.Shipping_AddressCard_ID.GetValueOrDefault(0) > 0 ? GetAddressCard(user.Shipping_AddressCard_ID.GetValueOrDefault(-1), true) : new AddressCard();
                info.ShippingFirstName = (user.BillingLikeShipping) ? BillingCard.FirstName : ShippingCard.FirstName;
                info.ShippingLastName  = (user.BillingLikeShipping) ? BillingCard.LastName : ShippingCard.LastName;
                info.ShippingMIName    = (user.BillingLikeShipping) ? BillingCard.MiddleName : ShippingCard.MiddleName;
                info.ShippingFax       = (user.BillingLikeShipping) ? BillingCard.Fax : ShippingCard.Fax;
                info.ShippingAddress1  = (user.BillingLikeShipping) ? BillingCard.Address1 : ShippingCard.Address1;
                info.ShippingAddress2  = (user.BillingLikeShipping) ? BillingCard.Address2 : ShippingCard.Address2;
                info.ShippingCity      = (user.BillingLikeShipping) ? BillingCard.City : ShippingCard.City;
                info.ShippingZip       = (user.BillingLikeShipping) ? BillingCard.Zip : ShippingCard.Zip;
                info.ShippingState     = (user.BillingLikeShipping) ? BillingCard.State : ShippingCard.State;
                info.ShippingWorkPhone = (user.BillingLikeShipping) ? BillingCard.WorkPhone : ShippingCard.WorkPhone;
                info.ShippingPhone     = (user.BillingLikeShipping) ? BillingCard.HomePhone : ShippingCard.HomePhone;
                info.ShippingCountry   = (user.BillingLikeShipping) ? BillingCard.Country_ID : ShippingCard.Country_ID;

                dco.Data = info;
                CacheRepository.Add(dco);
            }
            catch (Exception ex)
            {
                Logger.LogException("[user_id=" + user_id.ToString() + "]", ex);
                return(null);
            }
            return(info);
        }