Exemple #1
0
 /// <summary>
 /// Type all criteria in Main and Advanced Search options.
 /// </summary>
 /// <param name="offer"></param>
 internal void SearchOffers(SearchOffer offer)
 {
     this.SelectMultiselect(offer);
     this.Type(this.FromDate, offer.FromDate);
     this.Type(this.ToDate, offer.Todate);
     this.Type(this.SearchField, offer.SearchField);
 }
Exemple #2
0
        public async Task <ActionResult> SearchGames(int currentPage = 1, int formatId = 0, string gameName = "", int categoryId = 0)
        {
            SearchOffer SearchGames = new SearchOffer();

            SearchGames.GameName   = gameName;
            SearchGames.FormatId   = formatId;
            SearchGames.CategoryId = categoryId;

            var gameLogic       = LogicContext.Create <GameCatalogLogic>();
            var searchGamesData = await gameLogic.SearchGameCatalog(CurrentLoginSession.ApplicationUserId.GetValueOrDefault(), SearchGames, currentPage);

            var searchGamesTotalCount = await gameLogic.SearchGameCatalog(CurrentLoginSession.ApplicationUserId.GetValueOrDefault(), SearchGames, currentPage, true);

            TempData["searchCount"]     = searchGamesTotalCount.Count;
            TempData["searchGamesData"] = searchGamesData;
            TempData["currentPage"]     = currentPage;
            TempData["imgpath"]         = SearchGames.imgpath;
            TempData["gameName"]        = SearchGames.GameName;
            TempData["formatId"]        = SearchGames.FormatId;
            TempData["categoryId"]      = SearchGames.CategoryId;

            string view = Request.UrlReferrer.Segments[2];

            if (view == "MyGames")
            {
                return(RedirectToAction("MyGames", "Offer"));
            }
            else
            {
                return(RedirectToAction("CreateOffer", "Offer"));
            }
        }
Exemple #3
0
        public async Task <ActionResult> MyGames(int currentPage = 1, string searchGame = "", int formatId = 0, int categoryId = 0)
        {
            var offerlogic       = LogicContext.Create <OfferLogic>();
            var gameCatalogLogic = LogicContext.Create <GameCatalogLogic>();
            var myGames          = await gameCatalogLogic.GetAllGamesOfApplicationUser(CurrentLoginSession.ApplicationUserId.GetValueOrDefault());

            var pageSize = Convert.ToInt16(PageSize.AllGames);

            if (TempData["searchGamesData"] != null)
            {
                currentPage = Convert.ToInt16(TempData["currentPage"]);
                var searchCount = Convert.ToInt32(TempData["searchCount"]);
                var Pages       = offerlogic.PagingLogic(currentPage - 1, pageSize, searchCount);
                ViewBag.Pages          = Pages;
                ViewBag.FormatId       = TempData["formatId"];
                ViewBag.CategoryId     = TempData["categoryId"];
                ViewBag.GameName       = TempData["gameName"];
                ViewBag.GameCollection = TempData["searchGamesData"];
                ViewBag.SelectedPage   = currentPage;
                ViewBag.pageSize       = pageSize;
                ViewBag.CurrentPage    = currentPage;
            }
            else
            {
                SearchOffer Search = new SearchOffer();
                Search.GameName   = searchGame;
                Search.FormatId   = formatId;
                Search.CategoryId = categoryId;

                //var currentPage = selectedPage;
                var countAllGames = await gameCatalogLogic.SearchGameCatalog(CurrentLoginSession.ApplicationUserId.GetValueOrDefault(), Search, currentPage, true);

                var totalCount = Convert.ToInt32(countAllGames.Count);
                var Pages      = offerlogic.PagingLogic(currentPage, pageSize, totalCount);
                ViewBag.Pages          = Pages;
                ViewBag.FormatId       = 0;
                ViewBag.CategoryId     = 0;
                ViewBag.GameName       = "";
                ViewBag.GameCollection = await gameCatalogLogic.SearchGameCatalog(CurrentLoginSession.ApplicationUserId.GetValueOrDefault(), Search, currentPage, false);

                ViewBag.SelectedPage = currentPage;
                ViewBag.pageSize     = pageSize;
                ViewBag.CurrentPage  = currentPage;
            }

            var formatLogic = LogicContext.Create <FormatLogic>();
            var formats     = await formatLogic.GetAllFormats();

            ViewBag.Formats = new SelectList(formats, "Id", "Name");

            var categoryLogic = LogicContext.Create <CategoryLogic>();
            var categories    = await categoryLogic.GetAllCategories();

            ViewBag.Categories = new SelectList(categories, "Id", "Name");

            return(View(myGames));
        }
        public async Task <int> GetSearchOffersTotalCount(SearchOffer Data)
        {
            IEnumerable <DIBZ.Common.Model.Offer> Offers = null;

            Offers = await Db.Query <DIBZ.Common.Model.Offer>(o => o.OfferStatus == OfferStatus.Pending && o.GameCatalog.Name.ToLower().Contains(Data.GameName.ToLower().Trim()) &&
                                                              o.GameCatalog.FormatId == (Data.FormatId == 0 ? o.GameCatalog.FormatId : Data.FormatId) && o.GameCatalog.CategoryId == (Data.CategoryId == 0 ? o.GameCatalog.CategoryId : Data.CategoryId) &&
                                                              o.IsActive && !o.IsDeleted).OrderByDescending(g => g.CreatedTime).QueryAsync();

            return(Offers.Count());
        }
Exemple #5
0
        /// <summary>
        /// Select all options in Multiselect and close the dropdown.
        /// </summary>
        /// <param name="offer"></param>
        private void SelectMultiselect(SearchOffer offer)
        {
            string[] multi;
            string[] separators = { ",", ";" };
            multi = offer.State.Split(separators, StringSplitOptions.RemoveEmptyEntries);

            this.StateMultiselect.Click();
            foreach (var option in multi)
            {
                this.FindElement(By.XPath(string.Format("//*[contains(text(), 'Приета')]/../div[1]", option))).Click();
            }
            this.StateMultiselect.Click();
        }
        public async Task <List <OfferData> > SearchOffers(SearchOffer Data, int currentPage)
        {
            var pageSize    = Convert.ToInt16(PageSize.SearchOffer);
            int skipRecords = (currentPage - 1) * pageSize;
            IEnumerable <DIBZ.Common.Model.Offer> Offers = null;

            Offers = await Db.Query <DIBZ.Common.Model.Offer>(o => o.OfferStatus == OfferStatus.Pending &&
                                                              o.GameCatalog.Name.ToLower().Contains(Data.GameName.ToLower().Trim()) && o.GameCatalog.FormatId == (Data.FormatId == 0 ? o.GameCatalog.FormatId : Data.FormatId) &&
                                                              o.GameCatalog.CategoryId == (Data.CategoryId == 0 ? o.GameCatalog.CategoryId : Data.CategoryId) && o.IsActive && !o.IsDeleted).OrderByDescending(g => g.CreatedTime).QueryAsync();

            var offerData = Offers.Select(t => new OfferData
            {
                GameName        = t.GameCatalog.Name,
                GameId          = t.GameCatalogId,
                AppUserId       = t.ApplicationUserId,
                AppUserFullName = string.Concat(t.ApplicationUser.FirstName, " ", t.ApplicationUser.LastName),
                NickName        = t.ApplicationUser.NickName,
                GameImageId     = t.GameCatalog.GameImageId,
                GameFormat      = t.GameCatalog.Format.Name,
                OfferedTime     = DIBZ.Common.ConversionHelper.ConvertDateToTimeZone(t.CreatedTime),
                OfferId         = t.Id
            }).ToList();

            foreach (var item in offerData)
            {
                //DIBZ.Common.LogHelper.LogInfo("OfferedTime: " + item.OfferedTime);
                DateTime currentTime = DIBZ.Common.ConversionHelper.ConvertDateToTimeZone(DateTime.UtcNow);

                var time = DateTime.Now.Subtract(item.OfferedTime).TotalDays;
                if (time < 1)
                {
                    item.OfferedTimeValue = string.Concat(currentTime.Subtract(item.OfferedTime).Hours.ToString(), " Hours");
                    //Math.Round(time, 2, MidpointRounding.AwayFromZero).ToString();
                }
                else if (time <= 2)
                {
                    item.OfferedTimeValue = string.Concat(currentTime.Subtract(item.OfferedTime).Days.ToString(), " Day");
                }
                else if (time > 2)
                {
                    item.OfferedTimeValue = string.Concat(currentTime.Subtract(item.OfferedTime).Days.ToString(), " Days");
                }
            }
            return(offerData.OrderByDescending(o => o.OfferedTime).Skip(skipRecords).Take(pageSize).ToList());
        }
Exemple #7
0
        /// <summary>
        /// Open advanced search and select options. Doesn't click on Search button.
        /// </summary>
        /// <param name="offer"></param>
        internal void AdvancedSearch(SearchOffer offer)
        {
            this.AdditionalSearch.Click();

            this.SelectByText(this.HasRefinancig, offer.HasRefinancing);
            this.SelectByText(this.HasCodebtor, offer.HasCodebtor);
            this.Type(this.SearchFieldAdvanced, offer.SearchFieldAdvanced);

            try
            {
                this.SelectByText(this.Region, offer.Region);
                this.SelectByText(this.Area, offer.Area);
                this.SelectByText(this.SubArea, offer.SubArea);
            }
            catch (NoSuchElementException)
            {
            }
        }
        public async Task <ActionResult> SearchOffers(FormCollection formData)
        {
            SearchOffer search = new SearchOffer();

            search.GameName   = formData["gameName"];
            search.FormatId   = ConversionHelper.SafeConvertToInt32(formData["formatId"]);
            search.CategoryId = ConversionHelper.SafeConvertToInt32(formData["categoryId"]);

            var offerLogic = LogicContext.Create <OfferLogic>();

            //get all GamesCatalog
            var gameCatalogLogic = LogicContext.Create <GameCatalogLogic>();

            var gameCatalogList = await gameCatalogLogic.SearchGameCatalog(null, search);

            TempData["searchedGameData"] = gameCatalogList;
            return(RedirectToAction("Index", "GameCatalog"));
        }
Exemple #9
0
        public async Task <ActionResult> PossibleSwaps(int?id = 0, int currentPage = 1, int pageSize = 5, bool isLatestFirst = true, int formatId = 0, string gameName = "", string imgpath = "", int categoryId = 0)
        {
            var formatLogic = LogicContext.Create <FormatLogic>();
            var formats     = await formatLogic.GetAllFormats();

            ViewBag.Formats = new SelectList(formats, "Id", "Name");

            var categoryLogic = LogicContext.Create <CategoryLogic>();
            var categories    = await categoryLogic.GetAllCategories();

            ViewBag.Categories = new SelectList(categories, "Id", "Name");

            ViewBag.PageSize = pageSize;
            ViewBag.Sorting  = isLatestFirst;

            SearchOffer SearchRequest = new SearchOffer();

            SearchRequest.imgpath    = imgpath;
            SearchRequest.GameName   = gameName;
            SearchRequest.FormatId   = formatId;
            SearchRequest.CategoryId = categoryId;

            ViewBag.GameName   = SearchRequest.GameName;
            ViewBag.FormatId   = SearchRequest.FormatId;
            ViewBag.CategoryId = SearchRequest.CategoryId;

            var offerLogic = LogicContext.Create <OfferLogic>();

            SearchRequest.AppUserId             = CurrentLoginSession.ApplicationUser.Id;
            SearchRequest.AppUserRegisteredTime = CurrentLoginSession.ApplicationUser.CreatedTime;
            SearchRequest.OfferId = id.GetValueOrDefault();

            var possibleSwapDataCount = await offerLogic.ShowPossibleSwapToUser(SearchRequest, 1, 5, true, true);

            var Pages = offerLogic.PagingLogic(currentPage - 1, pageSize, Convert.ToInt32(possibleSwapDataCount.Count));

            ViewBag.Pages        = Pages;
            ViewBag.SelectedPage = currentPage;

            var possibleSwapData = await offerLogic.ShowPossibleSwapToUser(SearchRequest, currentPage, pageSize, isLatestFirst);

            return(View(possibleSwapData));
        }
Exemple #10
0
        public async Task <ActionResult> SearchOffer(int page, int?formatId, string gameName, int?categoryId, FormCollection formData)
        {
            SearchOffer search = new SearchOffer();

            if (formData.Count == 0)
            {
                if (gameName == "" || gameName == null)
                {
                    search.GameName = "";
                }
                else
                {
                    search.GameName = gameName;
                }
                search.FormatId   = Convert.ToInt32(formatId);
                search.CategoryId = Convert.ToInt32(categoryId);
            }
            else
            {
                search.GameName   = formData["gameName"];
                search.FormatId   = ConversionHelper.SafeConvertToInt32(formData["formatId"]);
                search.CategoryId = ConversionHelper.SafeConvertToInt32(formData["categoryId"]);
            }

            var offerLogic = LogicContext.Create <OfferLogic>();

            //get all GamesCatalog
            var searchOfferData = await offerLogic.SearchOffers(search, page);

            var searchOfferCount = await offerLogic.GetSearchOffersTotalCount(search);

            TempData["searchOfferCount"] = searchOfferCount;
            TempData["searchOfferData"]  = searchOfferData;
            TempData["currentPage"]      = page - 1;
            TempData["gameName"]         = search.GameName;
            TempData["formatId"]         = search.FormatId;
            TempData["categoryId"]       = search.CategoryId;
            return(RedirectToAction("Search", "Search"));
        }
Exemple #11
0
        public async Task <List <GameCatalogModel> > SearchGameCatalog(int?applicationUserId, SearchOffer Data, int currentPage = 1, bool isCount = false)
        {
            int pageSize    = Convert.ToInt16(PageSize.AllGames);
            int skipRecords = (currentPage - 1) * pageSize;
            IEnumerable <DIBZ.Common.Model.GameCatalog> gameCatalogs = null;

            var userData = await Db.GetObjectById <ApplicationUser>((int)applicationUserId);

            var userExistingGameIds = userData.GameCatalogs.Select(g => g.Id).ToList();

            gameCatalogs = await Db.Query <DIBZ.Common.Model.GameCatalog>(o => !userExistingGameIds.Contains(o.Id) && o.Name.ToLower().Contains(Data.GameName.ToLower().Trim()) && o.IsActive && !o.IsDeleted &&
                                                                          o.CategoryId == (Data.CategoryId == 0 ? o.CategoryId : Data.CategoryId) &&
                                                                          o.FormatId == (Data.FormatId == 0 ? o.FormatId : Data.FormatId)).OrderByDescending(g => g.CreatedTime).QueryAsync();

            var searchedData = Enumerable.Empty <GameCatalogModel>().ToList();

            if (isCount == true)
            {
                searchedData = gameCatalogs.Select(t => new GameCatalogModel
                {
                    Name         = t.Name,
                    FormatName   = t.Format.Name,
                    CategoryName = t.Category.Name,
                    Id           = t.Id,
                    IsFeatured   = t.IsFeatured,
                    GameImageId  = t.GameImageId,
                    imgpath      = t.imgpath,
                    sellprice    = t.sellprice,
                    cashprice    = t.cashprice,
                    voucherprice = t.voucherprice,
                }).ToList();
            }
            else
            {
                searchedData = gameCatalogs.Select(t => new GameCatalogModel
                {
                    Name         = t.Name,
                    FormatName   = t.Format.Name,
                    CategoryName = t.Category.Name,
                    Id           = t.Id,
                    IsFeatured   = t.IsFeatured,
                    GameImageId  = t.GameImageId,
                    imgpath      = t.imgpath,
                    sellprice    = t.sellprice,
                    cashprice    = t.cashprice,
                    voucherprice = t.voucherprice,
                }).Skip(skipRecords).Take(pageSize).ToList();
            }
            return(searchedData);
        }
        public async Task <List <OfferData> > ShowPossibleSwapToUser(SearchOffer Request, int currentPage = 1, int pageSize = 5, bool isLatestFirst = true, bool isCount = false)
        {
            int skipRecords      = (currentPage - 1) * pageSize;
            var gameCatalogLogic = LogicContext.Create <GameCatalogLogic>();
            var myGames          = (await gameCatalogLogic.GetAllGamesOfApplicationUser(Request.AppUserId)).Where(o => o.IsValidForOffer).Select(o => o.GameId).ToList();
            //&& myGames.Contains(o.ReturnGameCatalogId.Value)
            IEnumerable <DIBZ.Common.Model.Offer> offers = null;

            offers = await Db.Query <DIBZ.Common.Model.Offer>(o => o.ApplicationUserId != Request.AppUserId &&
                                                              (o.GameCatalog.Name.ToLower().Contains(Request.GameName.ToLower().Trim()) || o.ReturnGameCatalog.Name.ToLower().Contains(Request.GameName.ToLower().Trim())) &&
                                                              o.OfferStatus == OfferStatus.Pending && o.GameCatalog.FormatId == (Request.FormatId == 0 ? o.GameCatalog.FormatId : Request.FormatId) &&
                                                              o.GameCatalog.CategoryId == (Request.CategoryId == 0 ? o.GameCatalog.CategoryId : Request.CategoryId) && o.IsActive &&
                                                              !o.IsDeleted && o.ReturnGameCatalogId.HasValue && myGames.Contains(o.ReturnGameCatalogId.Value)).QueryAsync();

            var offerData = offers.Select(t => new OfferData
            {
                GameName           = t.GameCatalog.Name,
                GameId             = t.GameCatalogId,
                AppUserId          = t.ApplicationUserId,
                AppUserFullName    = string.Concat(t.ApplicationUser.FirstName, " ", t.ApplicationUser.LastName),
                NickName           = t.ApplicationUser.NickName,
                GameImageId        = t.GameCatalog.GameImageId,
                ReturnGameId       = t.ReturnGameCatalogId,
                GameFormat         = t.GameCatalog.Format.Name,
                OfferedTime        = DIBZ.Common.ConversionHelper.ConvertDateToTimeZone(t.CreatedTime),
                GameCategory       = t.GameCatalog.Category.Name,
                OfferId            = t.Id,
                ProfileImageId     = t.ApplicationUser.ProfileImageId,
                ReturnGameFormat   = t.ReturnGameCatalog.Format.Name,
                ReturnGameName     = t.ReturnGameCatalog.Name,
                IsCounterOfferMade = t.CounterOffers.Any(o => o.CounterOfferPersonId == Request.AppUserId),
                OfferStatus        = t.OfferStatus,
                IsPaymentRequired  = !t.Transactions.Any(p => p.ApplicationUserId == Request.AppUserId)
            }).ToList();

            var scorecardLogic = LogicContext.Create <ScorecardLogic>();

            foreach (var item in offerData)
            {
                //DIBZ.Common.LogHelper.LogInfo("OfferedTime: " + item.OfferedTime);
                DateTime currentTime = DIBZ.Common.ConversionHelper.ConvertDateToTimeZone(DateTime.UtcNow);

                item.Scorecard = await scorecardLogic.GetScoreCardByAppUserId(item.AppUserId);

                var time = DateTime.Now.Subtract(item.OfferedTime).TotalDays;
                if (time < 1)
                {
                    item.OfferedTimeValue = string.Concat(currentTime.Subtract(item.OfferedTime).Hours.ToString(), " Hours");
                }
                else if (time <= 2)
                {
                    item.OfferedTimeValue = string.Concat(Math.Round(time, 0).ToString(), " Day");
                }
                else if (time > 2)
                {
                    item.OfferedTimeValue = string.Concat(Math.Round(time, 0).ToString(), " Days");
                }
            }
            //Getting my counter offers againts those games which are not in my game list
            var myCounterOffers = await Db.Query <DIBZ.Common.Model.CounterOffer>(o => o.CounterOfferPersonId == Request.AppUserId && (o.Offer.OfferStatus == OfferStatus.Pending || o.Offer.OfferStatus == OfferStatus.NotAvailable) &&
                                                                                  !o.Offer.IsDeleted && o.IsActive && !o.IsDeleted && o.Offer.ReturnGameCatalogId.HasValue && !myGames.Contains(o.Offer.ReturnGameCatalogId.Value)).QueryAsync();

            var myCounterOffersData = myCounterOffers.Select(t => new OfferData
            {
                GameName           = t.Offer.GameCatalog.Name,
                GameId             = t.Offer.GameCatalogId,
                AppUserId          = t.Offer.ApplicationUserId,
                AppUserFullName    = string.Concat(t.Offer.ApplicationUser.FirstName, " ", t.Offer.ApplicationUser.LastName),
                NickName           = t.Offer.ApplicationUser.NickName,
                GameImageId        = t.Offer.GameCatalog.GameImageId,
                ReturnGameId       = t.Offer.ReturnGameCatalogId,
                GameFormat         = t.Offer.GameCatalog.Format.Name,
                OfferedTime        = DIBZ.Common.ConversionHelper.ConvertDateToTimeZone(t.CreatedTime),
                GameCategory       = t.Offer.GameCatalog.Category.Name,
                OfferId            = t.Offer.Id,
                ProfileImageId     = t.Offer.ApplicationUser.ProfileImageId,
                ReturnGameFormat   = t.Offer.ReturnGameCatalog.Format.Name,
                ReturnGameName     = t.Offer.ReturnGameCatalog.Name,
                IsCounterOfferMade = true,
                CounterOfferId     = t.Id,
                OfferStatus        = t.Offer.OfferStatus,
                IsPaymentRequired  = !t.Offer.Transactions.Any(p => p.ApplicationUserId == Request.AppUserId)
            }).ToList();

            foreach (var item in myCounterOffersData)
            {
                //DIBZ.Common.LogHelper.LogInfo("OfferedTime: " + item.OfferedTime);
                DateTime currentTime = DIBZ.Common.ConversionHelper.ConvertDateToTimeZone(DateTime.UtcNow);

                item.Scorecard = await scorecardLogic.GetScoreCardByAppUserId(item.AppUserId);

                var time = DateTime.Now.Subtract(item.OfferedTime).TotalDays;
                if (time < 1)
                {
                    item.OfferedTimeValue = string.Concat(currentTime.Subtract(item.OfferedTime).Hours.ToString(), " Hours");
                }
                else if (time <= 2)
                {
                    item.OfferedTimeValue = string.Concat(Math.Round(time, 0).ToString(), " Day");
                }
                else if (time > 2)
                {
                    item.OfferedTimeValue = string.Concat(Math.Round(time, 0).ToString(), " Days");
                }
            }
            offerData.AddRange(myCounterOffersData);

            // Get counter offers againts my offers
            var myOfferIds = (await Db.Query <DIBZ.Common.Model.Offer>(o => o.ApplicationUserId == Request.AppUserId && (o.OfferStatus == OfferStatus.NotAvailable ||
                                                                                                                         o.OfferStatus == OfferStatus.Pending) && o.IsActive && !o.IsDeleted).QueryAsync()).Select(o => o.Id).ToList();

            var counterOfferLogic = LogicContext.Create <CounterOfferLogic>();
            var counterOffers     = await counterOfferLogic.GetAllCounterOffers(myOfferIds);

            var counterOfferData = counterOffers.Select(t => new OfferData
            {
                GameName          = t.Offer.GameCatalog.Name,
                GameId            = t.Offer.GameCatalogId,
                AppUserId         = t.CounterOfferPersonId,
                AppUserFullName   = string.Concat(t.CounterOfferPerson.FirstName, " ", t.CounterOfferPerson.LastName),
                NickName          = t.CounterOfferPerson.NickName,
                GameImageId       = t.Offer.GameCatalog.GameImageId,
                ReturnGameId      = t.Offer.ReturnGameCatalogId,
                GameFormat        = t.Offer.GameCatalog.Format.Name,
                OfferedTime       = DIBZ.Common.ConversionHelper.ConvertDateToTimeZone(t.CreatedTime),
                GameCategory      = t.Offer.GameCatalog.Category.Name,
                OfferId           = t.Offer.Id,
                ProfileImageId    = t.CounterOfferPerson.ProfileImageId,
                ReturnGameFormat  = t.Offer.ReturnGameCatalog.Format.Name,
                ReturnGameName    = t.Offer.ReturnGameCatalog.Name,
                IsCounterOffer    = true,
                CounterOfferId    = t.Id,
                OfferStatus       = t.Offer.OfferStatus,
                IsPaymentRequired = !t.Offer.Transactions.Any(p => p.ApplicationUserId == Request.AppUserId)
            }).ToList();

            foreach (var item in counterOfferData)
            {
                //DIBZ.Common.LogHelper.LogInfo("OfferedTime: " + item.OfferedTime);
                DateTime currentTime = DIBZ.Common.ConversionHelper.ConvertDateToTimeZone(DateTime.UtcNow);

                item.Scorecard = await scorecardLogic.GetScoreCardByAppUserId(item.AppUserId);

                var time = DateTime.Now.Subtract(item.OfferedTime).TotalDays;
                if (time < 1)
                {
                    item.OfferedTimeValue = string.Concat(currentTime.Subtract(item.OfferedTime).Hours.ToString(), " Hours");
                }
                else if (time <= 2)
                {
                    item.OfferedTimeValue = string.Concat(Math.Round(time, 0).ToString(), " Day");
                }
                else if (time > 2)
                {
                    item.OfferedTimeValue = string.Concat(Math.Round(time, 0).ToString(), " Days");
                }
            }

            offerData.AddRange(counterOfferData);

            foreach (var item in offerData)
            {
                if (item.IsPaymentRequired && item.OfferedTime > Request.AppUserRegisteredTime)
                {
                    var offerForTimeCheck = await this.GetOfferById(item.OfferId);

                    if (offerForTimeCheck != null && offerForTimeCheck.UpdatedTime.HasValue && Math.Round(DateTime.Now.Subtract(offerForTimeCheck.UpdatedTime.Value).TotalHours) >= DIBZ.Common.SystemSettings.PaymentTimeInHours)
                    {
                        offerForTimeCheck.OfferStatus = OfferStatus.Pending;
                        item.OfferStatus = OfferStatus.Pending;
                        await scorecardLogic.UpdateScoreCardOfApplicationUserWithNoShow(Request.AppUserId);
                    }
                }
            }
            await Db.SaveAsync();

            if (isLatestFirst == true)
            {
                if (isCount == true)
                {
                    return(offerData.Where(o => o.OfferStatus == OfferStatus.Pending || o.OfferStatus == OfferStatus.PaymentNeeded).OrderByDescending(o => o.OfferedTime).ToList());
                }
                else
                {
                    return(offerData.Where(o => o.OfferStatus == OfferStatus.Pending || o.OfferStatus == OfferStatus.PaymentNeeded).OrderByDescending(o => o.OfferedTime).Skip(skipRecords).Take(pageSize).ToList());
                }
            }
            else
            {
                return(offerData.Where(o => o.OfferStatus == OfferStatus.Pending || o.OfferStatus == OfferStatus.PaymentNeeded).Skip(skipRecords).Take(pageSize).ToList());
            }
        }
Exemple #13
0
        public async Task <ActionResult> CreateOffer(int?id, int?offerId, int?gameId, int?returnGameId)
        {
            string view = ""; //Request.UrlReferrer;// == null ? null : Request.UrlReferrer.Segments[2];

            //if (view == "MyOffers")
            if (!id.HasValue)
            {
                DIBZ.Common.Model.GameCatalog selectedGame = new DIBZ.Common.Model.GameCatalog();
                var offerLogic = LogicContext.Create <OfferLogic>();
                selectedGame = await offerLogic.GetSelectedGameById(gameId);

                ViewBag.SelectedGame = selectedGame;

                selectedGame = await offerLogic.GetSelectedGameById(returnGameId);

                ViewBag.DesiredGame = selectedGame;
                ViewBag.OfferId     = offerId;
                ViewBag.View        = "EditOffer";
            }
            else
            {
                DIBZ.Common.Model.GameCatalog selectedGame = new DIBZ.Common.Model.GameCatalog();
                var offerLogic = LogicContext.Create <OfferLogic>();
                selectedGame = await offerLogic.GetSelectedGameById(id);

                ViewBag.SelectedGame = selectedGame;
                ViewBag.DesiredGame  = selectedGame;
            }

            var offerlogic       = LogicContext.Create <OfferLogic>();
            var gameCatalogLogic = LogicContext.Create <GameCatalogLogic>();
            var myGames          = await gameCatalogLogic.GetAllGamesOfApplicationUser(CurrentLoginSession.ApplicationUserId.GetValueOrDefault());

            var pageSize = Convert.ToInt16(PageSize.AllGames);

            if (TempData["searchGamesData"] != null)
            {
                var currentPage = Convert.ToInt16(TempData["currentPage"]);
                var searchCount = Convert.ToInt32(TempData["searchCount"]);
                var Pages       = offerlogic.PagingLogic(currentPage - 1, pageSize, searchCount);
                ViewBag.Pages          = Pages;
                ViewBag.FormatId       = TempData["formatId"];
                ViewBag.CategoryId     = TempData["categoryId"];
                ViewBag.GameName       = TempData["gameName"];
                ViewBag.GameCollection = TempData["searchGamesData"];
                ViewBag.SelectedPage   = currentPage;
                ViewBag.pageSize       = pageSize;
            }
            else
            {
                SearchOffer Search = new SearchOffer();
                Search.GameName   = "";
                Search.FormatId   = 0;
                Search.CategoryId = 0;

                var currentPage   = 1;
                var countAllGames = await gameCatalogLogic.SearchGameCatalog(CurrentLoginSession.ApplicationUserId.GetValueOrDefault(), Search, currentPage, true);

                var totalCount = Convert.ToInt32(countAllGames.Count);
                var Pages      = offerlogic.PagingLogic(currentPage, pageSize, totalCount);
                ViewBag.Pages          = Pages;
                ViewBag.FormatId       = 0;
                ViewBag.CategoryId     = 0;
                ViewBag.GameName       = "";
                ViewBag.GameCollection = await gameCatalogLogic.SearchGameCatalog(CurrentLoginSession.ApplicationUserId.GetValueOrDefault(), Search, currentPage, false);

                ViewBag.SelectedPage = 1;
                ViewBag.pageSize     = pageSize;
            }

            var formatLogic = LogicContext.Create <FormatLogic>();
            var formats     = await formatLogic.GetAllFormats();

            ViewBag.Formats = new SelectList(formats, "Id", "Name");

            var categoryLogic = LogicContext.Create <CategoryLogic>();
            var categories    = await categoryLogic.GetAllCategories();

            ViewBag.Categories = new SelectList(categories, "Id", "Name");

            return(View(myGames));
        }