예제 #1
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);
        }
예제 #2
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);
        }