public IActionResult Candidates(ContestantViewModel contestantViewModel) { string searchStr = contestantViewModel.name; int categoryStr = contestantViewModel.CategoryId; string queryString = "name=" + searchStr + '&' + "category=" + categoryStr; return(Redirect("~/contestants?" + queryString)); }
public async Task <IActionResult> Send(string receiver, ContestantViewModel input) { var senderId = _userManager.GetUserId(User); if (!this.ModelState.IsValid) { return(this.View(input)); } await this._messageService.Create(input.MessageInputModel.Title, input.MessageInputModel.Description, senderId, receiver); return(View(input)); }
public ActionResult AddContestant(ContestantViewModel model) { var c = new Contestant { GroupNum = model.GroupNum, Name = model.Name, Number = model.Number, CompetitionId = CompetitionId }; _context.Contestants.Add(c); _context.SaveChanges(); return(RedirectToAction("AddContestant")); //return RedirectToAction("ListContestant", new {id = CompetitionId}); }
public async Task <bool> FoundJoiningPlayer(ContestantViewModel contestant) { _logger.Trace(); return(await(_messageHubImplementation?.FoundJoiningPlayer(contestant) ?? Task.FromResult(false))); }
// [Route("candidates/all")] public async Task <IActionResult> Index(int currentPage = 1, string Sort = null) { var viewModel = new ContestantViewModel { AllLocations = _locationService.GetAllSelectList(), AllCategories = _categoriesService.GetAllSelectList() }; viewModel.Skills = _skillsService.GetAll <Skills>(viewModel.SkillsId, false); //viewModel.ReturnUrl = Url.Page(null, pageHandler: null, new { currentPage = currentPage }, protocol: Request.Scheme); var entity = _contestantsService.GetAllAsNoTracking() .Where(x => (x.isApproved == ApproveType.Success) && !x.isArchived && (x.profileVisiblity == 0)) .Select(x => new Contestant { Id = x.Id, FullName = x.FullName, LocationId = x.LocationId, CreatedOn = x.CreatedOn, PosterID = x.PosterID, RatingVotes = x.RatingVotes, payRate = x.payRate, SalaryType = x.SalaryType, Promotion = x.Promotion, About = x.About, userSkillsId = x.userSkillsId, LanguagesId = x.LanguagesId }); if (!String.IsNullOrEmpty(viewModel.LanguagesId)) { string[] langs = viewModel.LanguagesId?.Split(", "); entity = entity.Where(x => ((IList)langs).Contains(x.LanguagesId)); } if (!String.IsNullOrEmpty(viewModel.WorkType)) { string[] type = viewModel.WorkType?.Split("%2C"); entity = entity.Where(x => ((IList)type).Contains(x.WorkType)); } if (!String.IsNullOrEmpty(viewModel.LocationId)) { entity = entity.Where(s => s.LocationId.Equals(viewModel.LocationId)); } if (viewModel.CategoryId > 0) { entity = entity.Where(x => x.CategoryId == viewModel.CategoryId); } switch (Sort) { case "Рейтинг": entity = entity.OrderByDescending(x => x.RatingVotes); break; case "Последни": entity = entity.OrderBy(x => x.CreatedOn); break; case "Най-нови": entity = entity.OrderByDescending(x => x.CreatedOn); break; case "Заплата": entity = entity.OrderBy(x => x.payRate); break; default: entity = entity.OrderByDescending(x => x.CreatedOn); break; } if (await entity.AnyAsync()) // prevent 'SqlException: The offset specified in a OFFSET clause may not be negative.' { int count = await entity.AsQueryable().AsNoTracking().CountAsync().ConfigureAwait(false); viewModel.Pager = new Pager(count, currentPage); var result = entity .Skip((viewModel.Pager.CurrentPage - 1) * viewModel.Pager.PageSize) .Take(viewModel.Pager.PageSize); viewModel.Result = result.To <ContestantViewModel>().AsAsyncEnumerable(); } else { viewModel.Result = null; } return(View(viewModel)); }
public async Task <bool> FoundJoiningPlayer(ContestantViewModel contestant) { await Clients.All.NotifyPlayerJoined(contestant); return(true); }
public async Task <IActionResult> Index(ContestantViewModel viewModel, string name, int LocationId, int CategoryId, string WorkType, string userSkillsId, string LanguageId, int currentPage) { /* HttpRequest request = _httpcontext.HttpContext.Request; * string query = request.QueryString.Value; * * string newQuery = query.Substring(query.LastIndexOf("=") + 1) ; * var decryptedQuery = _chipherService.Decrypt(newQuery); */ ViewData["Categories"] = this._categoriesService.GetAllAsNoTrackingMapped().Select(x => new SelectListItem { Value = x.Id.ToString(), Text = x.TitleAndCountContestant, }); ViewData["Locations"] = this._locationService.GetAllAsNoTrackingMapped().Select(x => new SelectListItem { Value = x.Id.ToString(), Text = x.City, }); var entity = _contestantsService.GetAllAsNoTrackingMapped().Where(x => x.isApproved == 2 && (x.profileVisiblity == 0)); if (!String.IsNullOrEmpty(name)) { entity = entity.Where(s => s.Name.ToLower().Contains(name)); } if (!String.IsNullOrEmpty(LanguageId)) { string[] langs = LanguageId?.Split(','); entity = entity.Where(x => ((IList)langs).Contains(x.LanguagesId)); } if (!String.IsNullOrEmpty(userSkillsId)) { string[] tags = userSkillsId?.Split("%2C"); entity = entity.Where(x => ((IList)tags).Contains(x.userSkillsId)); } if (!String.IsNullOrEmpty(WorkType)) { string[] type = WorkType?.Split("%2C"); entity = entity.Where(x => ((IList)type).Contains(x.WorkType)); } if (CategoryId > 0) { entity = entity.Where(x => x.CategoryId == CategoryId); } if (LocationId > 0) { entity = entity.Where(x => x.LocationId == LocationId); } else { entity = entity.OrderByDescending(x => x.Id); } Count = await entity.CountAsync().ConfigureAwait(false); if (Count > 0) // prevent 'SqlException: The offset specified in a OFFSET clause may not be negative.' { CurrentPage = currentPage == 0 ? 1 : currentPage; if (CurrentPage > TotalPages) { CurrentPage = TotalPages; } var result = entity .Skip((CurrentPage - 1) * PageSize) .Take(PageSize) .AsQueryable() .ToAsyncEnumerable(); ViewBag.Count = Count; ViewBag.CurrentPage = CurrentPage; ViewBag.TotalPages = TotalPages; ViewBag.PageSize = PageSize; ViewData["Candidates"] = result; } else { ViewData["Candidates"] = null; } // var entity2 = entity.Where(x => x.Id == 2); // ViewData["ProfileModal"] = entity2; return(View(viewModel)); }