Beispiel #1
0
        internal AuctionItemViewModel ViewSellerAuction(string sellerEmail)
        {
            AuctionModel postedAuctionModel = new AuctionModel();
            BidModel     bidInfoModel       = new BidModel();
            ABUserModel  bidderInfoModel    = new ABUserModel();


            var sellerInfoObj = _abUserRepository.FindBy(x => x.Email == sellerEmail).FirstOrDefault();

            var postedAuctionObj = _auctionRepository.FindBy(x => x.AuctionGUID == sellerInfoObj.ABUser_AuctionGUID).FirstOrDefault();

            var bidInfoObj = _bidRepository.FindBy(x => x.Bid_AuctionGUID == postedAuctionObj.AuctionGUID).FirstOrDefault();

            try
            {
                var auctionBidderObj = _abUserRepository.FindBy(x => x.ABUserGUID == bidInfoObj.Bid_ABUserGUID && x.ABUser_AuctionGUID == bidInfoObj.Bid_AuctionGUID).FirstOrDefault();

                bidderInfoModel.Alias = auctionBidderObj.Alias;

                bidInfoModel.BidPlaced = bidInfoObj.BidPlaced;
            }
            catch
            {
                bidderInfoModel.Alias  = "No Bidders";
                bidInfoModel.BidPlaced = -1;
            }


            postedAuctionModel.AuctionGUID   = postedAuctionObj.AuctionGUID;
            postedAuctionModel.ItemName      = postedAuctionObj.ItemName;
            postedAuctionModel.StartingBid   = postedAuctionObj.StartingBid;
            postedAuctionModel.StartDate     = postedAuctionObj.StartDate;
            postedAuctionModel.EndDate       = postedAuctionObj.EndDate;
            postedAuctionModel.AuctionOver   = postedAuctionObj.AuctionOver;
            postedAuctionModel.SellerSent    = postedAuctionObj.SellerSent;
            postedAuctionModel.BuyerReceived = postedAuctionObj.BuyerReceived;


            if (postedAuctionObj != null)
            {
                if (bidInfoModel != null)
                {
                    return(new AuctionItemViewModel()
                    {
                        auctionItem = postedAuctionModel,
                        bidderInfo = bidderInfoModel,
                        bidInfo = bidInfoModel
                    });
                }
                else
                {
                    return(new AuctionItemViewModel()
                    {
                        auctionItem = postedAuctionModel
                    });
                }
            }

            return(null);
        }
Beispiel #2
0
        internal ServiceResult AddBidderAccount(BAccountCreateViewModel vm, Guid auctionGuid)
        {
            ABUserModel abuserModel = new ABUserModel();

            abuserModel.Alias              = vm.Alias;
            abuserModel.Email              = vm.EmailAddress;
            abuserModel.Password           = vm.Password;
            abuserModel.ABUserGUID         = Guid.NewGuid();
            abuserModel.ABUser_AuctionGUID = auctionGuid;
            abuserModel.Money              = vm.Money;

            ABUser addBidderSuccess = SaveBidderAccount(abuserModel);
            bool   commitSuccess    = UpdateUser(addBidderSuccess);

            if (commitSuccess)
            {
                return(new ServiceResult()
                {
                    Success = true,
                    Params = addBidderSuccess.ToString()
                });
            }

            return(new ServiceResult()
            {
                ErrorMessage = "Error message",
                Success = false
            });
        }
Beispiel #3
0
        /*
         * This function is for updatig user or equal to add a new seller into system
         */
        internal ServiceResult AddAccount(AccountCreateViewModel vm)
        {
            ABUserModel abuserModel = new ABUserModel();

            abuserModel.Alias    = vm.Alias;
            abuserModel.Email    = vm.EmailAddress;
            abuserModel.Password = vm.Password;
            abuserModel.Token    = null;

            ABUser currentUser = GetUserByUserName(vm.EmailAddress);

            currentUser.Alias    = vm.Alias;
            currentUser.Password = vm.Password;
            currentUser.Token    = null;

            _userRepository.Update(currentUser);


            bool commitSuccess = UpdateUser(currentUser);

            if (commitSuccess)
            {
                return(new ServiceResult()
                {
                    Success = true,
                    Params = currentUser.ToString()
                });
            }

            return(new ServiceResult()
            {
                ErrorMessage = "Error message",
                Success = false
            });
        }
Beispiel #4
0
        private ABUser SaveAccount(ABUserModel abuserModel)
        {
            var    role   = getGUID();
            ABUser abuser = new ABUser()
            {
                ABUserGUID = Guid.NewGuid(),
                Alias      = abuserModel.Alias,
                Email      = abuserModel.Email,
                Password   = abuserModel.Password,
                Role       = role
            };

            _userRepository.Add(abuser);
            return(abuser);
        }
Beispiel #5
0
        private ABUser SaveBidderAccount(ABUserModel abuserModel)
        {
            var    role   = getBidderRoleGUID();
            ABUser abuser = new ABUser()
            {
                ABUserGUID         = Guid.NewGuid(),
                Alias              = abuserModel.Alias,
                Email              = abuserModel.Email,
                Password           = abuserModel.Password,
                Role               = role,
                Money              = abuserModel.Money,
                ABUser_AuctionGUID = abuserModel.ABUser_AuctionGUID
            };

            _userRepository.Add(abuser);
            return(abuser);
        }
Beispiel #6
0
        private Guid SaveSeller(ABUserModel ABUserModel, Guid auctionGUID)
        {
            Guid sellerRoleGuid = _userRoleRepository.FindBy(x => x.UserRoleName == "SELLER").FirstOrDefault().UserRoleGUID;

            if (sellerRoleGuid != null && sellerRoleGuid != Guid.Empty)
            {
                ABUser abUser = new ABUser()
                {
                    ABUserGUID          = Guid.NewGuid(),
                    ABUser_AuctionGUID  = auctionGUID,
                    ABUser_UserRoleGUID = sellerRoleGuid,
                    Email = ABUserModel.Email,
                };
                _abUserRepository.Add(abUser);
                return(abUser.ABUserGUID);
            }
            return(Guid.Empty);
        }
Beispiel #7
0
        private ServiceResult ValidateSeller(ABUserModel abUserModel)
        {
            ServiceResult results = new ServiceResult
            {
                ErrorMessage = string.Empty
            };

            if (abUserModel == null || abUserModel.Email == string.Empty || abUserModel.Email == null)
            {
                results.ErrorMessage = "Email is not a valid email\n";
            }
            try
            {
                MailAddress validEmail = new MailAddress(abUserModel.Email);
            }
            catch (FormatException)
            {
                results.ErrorMessage = "Invalid email formats\n";
            }

            results.Success = results.ErrorMessage == string.Empty ? true : false;
            return(results);
        }