public async Task <IActionResult> Edit(MatchSeriesdto matchSeries) { if (ModelState.IsValid) { var directory = Path.Combine(_hosting.WebRootPath, "Home", "images", "Series"); if (!Directory.Exists(directory)) { Directory.CreateDirectory(directory); } if (matchSeries.SeriesImage != null) { matchSeries.FileName = matchSeries.SeriesImage.FileName; using (var stream = new FileStream(Path.Combine(directory, matchSeries.FileName), FileMode.Create)) { await matchSeries.SeriesImage.CopyToAsync(stream); } } var users = await _userManager.GetUserAsync(HttpContext.User); var matchSeriesModal = _mapper.Map <MatchSeries>(matchSeries); matchSeriesModal.UserId = users.Id; _context.MatchSeries.Update(matchSeriesModal); await _context.SaveChangesAsync(); return(Json(ResponseHelper.UpdateSuccess())); } return(Json(ResponseHelper.UpdateUnSuccess())); }
public async Task <IActionResult> Create(MatchSeriesdto matchSeries) { if (ModelState.IsValid) { var users = await _userManager.GetUserAsync(HttpContext.User); var matchSeriesModal = _mapper.Map <MatchSeries>(matchSeries); matchSeriesModal.UserId = users.Id; _context.MatchSeries.Add(matchSeriesModal); await _context.SaveChangesAsync(); return(Json(ResponseHelper.Success())); } return(View(matchSeries)); }