//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; }
//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); }
//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; }
//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); }