public async Task <IActionResult> GetPaging([FromQuery] MatchBindingModel collection) { if (string.IsNullOrWhiteSpace(collection?.Token)) { return(BadRequest(GeneralMessage.TokenNotFound)); } if (string.IsNullOrWhiteSpace(collection?.DeviceId)) { return(BadRequest(GeneralMessage.DeviceIdNotFound)); } try { var model = _mapper.Map <PredictionGetPagingSchema>(collection); var result = await _predictionService.GetPagingAsync(model); switch (model.StatusCode) { case 1: return(Ok(data: _mapper.Map <IEnumerable <PredictionViewModel> >(result), totalPages: collection.TotalPages(model.RowsCount))); case -1: return(BadRequest(GeneralMessage.UserNotFound)); case -2: return(BadRequest(GeneralMessage.UserIsNotActive)); case -3: return(BadRequest(GeneralMessage.PhoneIsNotVerified)); } } catch (Exception ex) { await _exceptionService.InsertAsync(ex, URL, IP); } return(InternalServerError()); }
public IActionResult Add() { var model = new MatchBindingModel { AvailableGroups = this.SetAvailableGroups() }; return(this.View(model)); }
public async Task <IActionResult> Add(MatchBindingModel model) { if (!this.ModelState.IsValid) { model.AvailableGroups = this.SetAvailableGroups(); return(this.View(model)); } var match = this.mapper.Map <Match>(model); await this.ms.CreateMatch(match); this.TempData["SuccessMsg"] = "Match game has been added successfully."; return(this.RedirectToAction("Index")); }
async public Task <ActionResult> CreateMatch([Bind(Include = "GladiatorID, OpponentID")] MatchBindingModel model) { if (!ModelState.IsValid) { var errorList = ModelState.Values.SelectMany(m => m.Errors) .Select(e => e.ErrorMessage) .ToList(); Response.StatusCode = (int)HttpStatusCode.BadRequest; return(Json(errorList)); } string userId = User.Identity.GetUserId(); await GladiatorHandler.CreateMatch(model, userId); return(RedirectToAction("Index")); }