//Create public static SessionUser Create(IUser user) { AddressCard ac = ProjectConfig.Config.DataProvider.GetInstance().UserRepository.GetAddressCard(user.Billing_AddressCard_ID.GetValueOrDefault(-1), true); AddressCard ac2 = ProjectConfig.Config.DataProvider.GetInstance().UserRepository.GetAddressCard((user.BillingLikeShipping || !user.Shipping_AddressCard_ID.HasValue? user.Billing_AddressCard_ID:user.Shipping_AddressCard_ID).GetValueOrDefault(-1), true); return(new SessionUser(user.ID, user.Login, ac.FirstName, ac.LastName, user.UserType, user.Status, user.NotRecievingBidConfirmation, user.NotRecievingOutBidNotice, user.NotRecievingLotSoldNotice, user.NotRecievingLotClosedNotice, user.NotRecieveWeeklySpecials, user.NotRecieveNewsUpdates, user.CommRate_ID, user.IsConsignorShip, String.Format("{0}, {1}", ac.City, ac.State), user.Email, user.BillingLikeShipping, ac, ac2, user.IP)); }
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; }
//SessionUser public SessionUser(long id, string l, string fn, string ln, byte type, byte status, bool rbc, bool robn, bool rlsn, bool rlcn, bool rws, bool rnu, int commrate_id, string email, bool isbillinglikeshipping, AddressCard b, AddressCard s, string ip) { ID = id; Login = l; FirstName = fn; LastName = ln; UserType = type; Status = status; IsRecievingBidConfirmation = rbc; IsRecievingOutBidNotice = robn; IsRecievingLotSoldNotice = rlsn; IsRecievingLotClosedNotice = rlcn; IsRecieveWeeklySpecials = rws; IsRecieveNewsUpdates = rnu; CommRate_ID = commrate_id; Email = email; IsAddressBillingLikeShipping = isbillinglikeshipping; Address_Billing = new Address { Address_1 = b.Address1, Address_2 = b.Address2, City = b.City, Country_ID = b.Country_ID, State_ID = b.State_ID, Zip = b.Zip, Country = ProjectConfig.Config.DataProvider.GetInstance().DifferentRepository.GetCountry(b.Country_ID).Title, State = b.State, HomePhone = b.HomePhone, WorkPhone = b.WorkPhone, FirstName = b.FirstName, LastName = b.LastName, MiddleName = b.MiddleName }; Address_Shipping = new Address { Address_1 = s.Address1, Address_2 = s.Address2, City = s.City, Country_ID = s.Country_ID, State_ID = s.State_ID, Zip = s.Zip, Country = ProjectConfig.Config.DataProvider.GetInstance().DifferentRepository.GetCountry(s.Country_ID).Title, State = s.State, HomePhone = s.HomePhone, WorkPhone = s.WorkPhone, FirstName = s.FirstName, LastName = s.LastName, MiddleName = s.MiddleName }; IP = ip; }
//SessionUser public SessionUser(long id, string l, string fn, string ln, byte type, byte status, bool rbc, bool robn, bool rlsn, bool rlcn, bool rws, bool rnu, int commrate_id, bool isconsh, string slocation, string email, bool isbillinglikeshipping, AddressCard b, AddressCard s, string ip) { ID = id; Login = l; FirstName = fn; LastName = ln; UserType = type; Status = status; NotRecievingBidConfirmation = rbc; NotRecievingOutBidNotice = robn; NotRecievingLotSoldNotice = rlsn; NotRecievingLotClosedNotice = rlcn; NotRecieveWeeklySpecials = rws; NotRecieveNewsUpdates = rnu; CommRate_ID = commrate_id; IsConsignorShip = isconsh; SellerLocation = slocation; Email = email; IsAddressBillingLikeShipping = isbillinglikeshipping; Country country = ProjectConfig.Config.DataProvider.GetInstance().CountryRepository.GetCountryByID(b.Country_ID); Address_Billing = new Address { Address_1 = b.Address1, Address_2 = b.Address2, City = b.City, Country_ID = b.Country_ID, State_ID = b.State_ID, Zip = b.Zip, Country = country.Title, State = b.State, HomePhone = b.HomePhone, WorkPhone = b.WorkPhone, Fax = b.Fax, FirstName = b.FirstName, LastName = b.LastName, MiddleName = b.MiddleName }; country = ProjectConfig.Config.DataProvider.GetInstance().CountryRepository.GetCountryByID(s.Country_ID); Address_Shipping = new Address { Address_1 = s.Address1, Address_2 = s.Address2, City = s.City, Country_ID = s.Country_ID, State_ID = s.State_ID, Zip = s.Zip, Country = country.Title, State = s.State, HomePhone = s.HomePhone, WorkPhone = s.WorkPhone, Fax = s.Fax, FirstName = s.FirstName, LastName = s.LastName, MiddleName = s.MiddleName }; IP = ip; }
//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; }
[VauctionAuthorize, Compress, HttpPost, ValidateAntiForgeryTokenWrapper(HttpVerbs.Post)] // AcceptVerbs(HttpVerbs.Get | HttpVerbs.Post) public ActionResult PlaceBid(long?id, bool?ProxyBidding, decimal?BidAmount, decimal?RealBidAmount) { if (!id.HasValue) { return(RedirectToAction("Category", "Auction")); } AuctionDetail auction = AuctionRepository.GetAuctionDetail(id.GetValueOrDefault(-1), true); if (auction == null) { return(RedirectToAction("Category", "Auction")); } if (!auction.IsCurrentEvent || auction.Status == Consts.AuctionStatus.Closed || auction.DateEnd.CompareTo(DateTime.Now) < 0 || (!ProxyBidding.HasValue || !BidAmount.HasValue)) { return(RedirectToAction("AuctionDetail", "Auction", new { @id = auction.LinkParams.ID })); } SessionUser cuser = AppHelper.CurrentUser; if (!AuctionRepository.IsUserWatchItem(cuser.ID, auction.LinkParams.ID)) { AuctionRepository.AddItemToWatchList(cuser.ID, auction.LinkParams.ID); } PreviewBid previewBid = new PreviewBid { LinkParams = auction.LinkParams, IsProxy = ProxyBidding.Value, Amount = BidAmount.Value, Quantity = 1, RealAmount = RealBidAmount.GetValueOrDefault(0) }; byte result; BidCurrent currentBid = new BidCurrent { Amount = BidAmount.GetValueOrDefault(0), Auction_ID = id.Value, DateMade = DateTime.Now, IP = Consts.UsersIPAddress, IsActive = true, IsProxy = ProxyBidding.GetValueOrDefault(false), MaxBid = BidAmount.GetValueOrDefault(0), Quantity = 1, User_ID = cuser.ID }; BidCurrent previousBid, loserBid, winnerBid; result = BidRepository.BiddingForSingleAuction(auction, currentBid, out previousBid, out loserBid, out winnerBid); if (result == 3) { return(RedirectToAction("AuctionDetail", new { id.Value })); } AuctionRepository.RemoveAuctionResultsCache(id.Value); BidRepository.RemoveTopBidForItemCache(id.Value); BidRepository.UpdateUsersTopBidCache(id.Value, cuser.ID, currentBid); if (result == 1) { previewBid.Amount = winnerBid.Amount; if (cuser.IsRecievingOutBidNotice && !String.IsNullOrEmpty(cuser.Email) && !cuser.IsHouseBidder) { Mail.SendOutBidLetter(cuser.FirstName, cuser.LastName, cuser.Email, auction.LinkParams.Lot.ToString(), auction.LinkParams.Title, winnerBid.Amount.GetCurrency(), auction.EventDateEnd > DateTime.Now ? auction.EventDateEnd.ToString() : DateTime.Now.Date.ToShortDateString(), auction.LinkParams.AuctionDetailUrl); } return(View("OutBid", previewBid)); } if (cuser.IsRecievingBidConfirmation && !String.IsNullOrEmpty(cuser.Email) && !cuser.IsHouseBidder) { if (result == 2) { Mail.SendSuccessfulBidUpdateLetter(cuser.FirstName, cuser.LastName, cuser.Email, auction.LinkParams.Lot.ToString(), auction.LinkParams.Title, currentBid.Amount.GetCurrency(), currentBid.MaxBid.GetCurrency(), auction.EventDateEnd > DateTime.Now ? auction.EventDateEnd.ToString() : DateTime.Now.Date.ToShortDateString(), auction.LinkParams.AuctionDetailUrl, currentBid.MaxBid > previousBid.MaxBid); } else { Mail.SendSuccessfulBidLetter(cuser.FirstName, cuser.LastName, cuser.Email, auction.LinkParams.Lot.ToString(), auction.LinkParams.Title, currentBid.Amount.GetCurrency(), BidAmount.GetCurrency(), auction.EventDateEnd > DateTime.Now ? auction.EventDateEnd.ToString() : DateTime.Now.Date.ToShortDateString(), auction.LinkParams.AuctionDetailUrl); } } if (loserBid != null && loserBid.User_ID != cuser.ID) { User usr = dataProvider.UserRepository.GetUser(loserBid.User_ID, true); if (usr.IsRecievingOutBidNotice && !String.IsNullOrEmpty(usr.Email) && !usr.IsHouseBidder) { AddressCard ac = dataProvider.UserRepository.GetAddressCard(usr.Billing_AddressCard_ID.GetValueOrDefault(-1), true); Mail.SendOutBidLetter(ac.FirstName, ac.LastName, usr.Email, auction.LinkParams.Lot.ToString(), auction.LinkParams.Title, winnerBid.Amount.GetCurrency(), auction.EventDateEnd > DateTime.Now ? auction.EventDateEnd.ToString() : DateTime.Now.Date.ToShortDateString(), auction.LinkParams.AuctionDetailUrl); } } /* * * BidCurrent prevBid = BidRepository.GetUserTopBidForItem(id.Value, cuser.ID, false); * if (prevBid != null && (prevBid.IsProxy == ProxyBidding) && prevBid.MaxBid >= BidAmount) return RedirectToAction("AuctionDetail", "Auction", new { @id = id }); * * BidCurrent lastTop = BidRepository.GetTopBidForItem(id.Value); * decimal lastMaxBid = (lastTop == null) ? 0 : lastTop.MaxBid; * decimal lastamount = (lastTop == null) ? 0 : lastTop.Amount; * * BiddingObject placedBid = BidRepository.PlaceSingleBid(id.Value, ProxyBidding.Value, BidAmount.Value, cuser.ID, 1, (lastTop != null && lastTop.User_ID == cuser.ID && ProxyBidding.Value), auction.Price, prevBid, lastTop); * * List<BidLogCurrent> newblogs = new List<BidLogCurrent>(); * BidRepository.ResolveProxyBiddingSituation(id.Value, cuser.ID, ProxyBidding.Value, placedBid, lastTop, auction.Price, newblogs); * * BidCurrent currentTop = BidRepository.GetTopBidForItem(id.Value); * BidRepository.UpdateUsersTopBid(id.Value, AppSession.CurrentUser.ID, placedBid.Bid); * bool IsOutBidden = (lastTop != null && currentTop.MaxBid <= lastTop.MaxBid && currentTop.User_ID != cuser.ID); * if (IsOutBidden) * { * if (placedBid.Bid.Amount >= currentTop.Amount) * { * currentTop.Amount = placedBid.Bid.Amount; * BidRepository.UpdateCurrentBid(currentTop); * } * if (lastamount < currentTop.Amount && newblogs.Where(BL=>BL.User_ID ==currentTop.User_ID && BL.Amount ==currentTop.Amount && BL.MaxBid==currentTop.MaxBid && BL.IsProxy == currentTop.IsProxy).Count()==0) * BidRepository.AddBidLogCurrent(id.Value, currentTop.Quantity, currentTop.User_ID, currentTop.IsProxy, currentTop.Amount, currentTop.MaxBid, false, currentTop.IP); * previewBid.Amount = currentTop.Amount; * try * { * if (cuser.IsRecievingOutBidNotice && !String.IsNullOrEmpty(cuser.Email) && !cuser.IsHouseBidder) * Mail.SendOutBidLetter(cuser.FirstName, cuser.LastName, cuser.Email, auction.LinkParams.Lot.ToString(), auction.LinkParams.Title, currentTop.Amount.GetCurrency(), auction.EventDateEnd > DateTime.Now ? auction.EventDateEnd.ToString() : DateTime.Now.Date.ToShortDateString(), auction.LinkParams.AuctionDetailUrl); * } * catch (Exception ex) * { * Utils.Lib.Logger.LogException(ex); * } * AuctionRepository.UpdateAuctionBiddingResult(id.Value, currentTop.User_ID, currentTop.Amount, currentTop.MaxBid); * return View("OutBid", previewBid); * } * AuctionRepository.UpdateAuctionBiddingResult(id.Value, currentTop.User_ID, currentTop.Amount, currentTop.MaxBid); * if (lastTop != null && lastTop.User_ID!=cuser.ID) * { * User usr = dataProvider.UserRepository.GetUser(lastTop.User_ID, true); * AddressCard ac = dataProvider.UserRepository.GetAddressCard(usr.Billing_AddressCard_ID.GetValueOrDefault(-1), true); * if (usr.IsRecievingOutBidNotice && !String.IsNullOrEmpty(usr.Email) && !usr.IsHouseBidder) * { * try * { * Mail.SendOutBidLetter(ac.FirstName, ac.LastName, usr.Email, auction.LinkParams.Lot.ToString(), auction.LinkParams.Title, placedBid.Bid.Amount.GetCurrency(), auction.EventDateEnd > DateTime.Now ? auction.EventDateEnd.ToString() : DateTime.Now.Date.ToShortDateString(), auction.LinkParams.AuctionDetailUrl); * } * catch (Exception ex) * { * Utils.Lib.Logger.LogException(ex); * } * } * } * * try * { * if (cuser.IsRecievingBidConfirmation && !String.IsNullOrEmpty(cuser.Email) && !cuser.IsHouseBidder) * { * if (lastTop == null || lastTop.User_ID != cuser.ID) * { * Mail.SendSuccessfulBidLetter(cuser.FirstName, cuser.LastName, cuser.Email, auction.LinkParams.Lot.ToString(), auction.LinkParams.Title, placedBid.Bid.Amount.GetCurrency(), BidAmount.GetCurrency(), auction.EventDateEnd > DateTime.Now ? auction.EventDateEnd.ToString() : DateTime.Now.Date.ToShortDateString(), auction.LinkParams.AuctionDetailUrl); * } * else * { * Mail.SendSuccessfulBidUpdateLetter(cuser.FirstName, cuser.LastName, cuser.Email, auction.LinkParams.Lot.ToString(), auction.LinkParams.Title, currentTop.Amount.GetCurrency(), currentTop.MaxBid.GetCurrency(), auction.EventDateEnd > DateTime.Now ? auction.EventDateEnd.ToString() : DateTime.Now.Date.ToShortDateString(), auction.LinkParams.AuctionDetailUrl, (lastMaxBid < currentTop.MaxBid)); * } * } * } * catch (Exception ex) * { * Utils.Lib.Logger.LogException(ex); * }*/ return(View("SuccessfulBid", auction)); }
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 : "")); }
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); }