Exemplo n.º 1
0
        public async Task <IActionResult> PastRecordSave(PlayerPastRecorddto playerPastRecord)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    var model = _mapper.Map <PlayerPastRecord>(playerPastRecord);
                    _context.Update(model);
                    await _context.SaveChangesAsync();
                }
                catch (Exception ex)
                {
                    return(BadRequest(new { Error = ex, Data = playerPastRecord, ModelState }));
                }

                return(Json(ResponseHelper.UpdateSuccess()));
            }
            return(BadRequest(ModelState));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Edit(Matchdto match)
        {
            if (ModelState.IsValid)
            {
                if (match.MatchImage != null)
                {
                    match.FileName = match.MatchImage.FileName;
                    using (var stream = new FileStream(Path.Combine(_hosting.WebRootPath, "Home", "Images", "Matches", match.FileName), FileMode.Create))
                    {
                        await match.MatchImage.CopyToAsync(stream);
                    }
                }
                var users = await _userManager.GetUserAsync(HttpContext.User);

                match.UserId = users.Id;
                _context.Update(_mapper.Map <Match>(match));
                await _context.SaveChangesAsync();

                return(Json(ResponseHelper.UpdateSuccess()));
            }
            return(Json(ResponseHelper.UpdateUnSuccess()));
        }
        public async Task <IActionResult> PlayerScoreModal([FromBody] MatchSummarydto playerScores)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var playercoreCard = _context.PlayerScores
                                         .AsNoTracking()
                                         .Where(i => i.PlayerScoreId == playerScores.PlayerScoreId)
                                         .SingleOrDefault();
                    playercoreCard.Bat_Runs  = playerScores.Bat_Runs;
                    playercoreCard.Bat_Balls = playerScores.Bat_Balls;
                    playercoreCard.Four      = playerScores.Four;
                    playercoreCard.Six       = playerScores.Six;
                    playercoreCard.Ball_Runs = playerScores.Ball_Runs;
                    playercoreCard.Overs     = playerScores.Overs;
                    playercoreCard.Wickets   = playerScores.Wickets;
                    playercoreCard.Maiden    = playerScores.Maiden;
                    playercoreCard.RunOut    = playerScores.RunOut;
                    playercoreCard.Catches   = playerScores.Catches;
                    playercoreCard.Stump     = playerScores.Stump;
                    _context.Update(playercoreCard);
                    await _context.SaveChangesAsync();

                    return(Ok());
                }
                else
                {
                    return(BadRequest(ModelState));
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                return(BadRequest());
            }
        }
Exemplo n.º 4
0
        public async Task <IActionResult> Edit(Matchdto match)
        {
            if (ModelState.IsValid)
            {
                var    form      = Request.Form;
                byte[] fileBytes = null;
                if (match.MatchImage != null)
                {
                    using (var stream = match.MatchImage.OpenReadStream())
                    {
                        fileBytes = ReadStream(stream);
                    }
                }
                var users = await _userManager.GetUserAsync(HttpContext.User);

                match.UserId    = users.Id;
                match.MatchLogo = fileBytes ?? null;
                _context.Update(_mapper.Map <Match>(match));
                await _context.SaveChangesAsync();

                return(Json(ResponseHelper.UpdateSuccess()));
            }
            return(Json(ResponseHelper.UpdateUnSuccess()));
        }