public async Task <IActionResult> Create([Bind("TransactionId,Email,Type,OldPhotoPath,NewPhotoPath,AcceptedVote,RejectedVote,VoteRequired,FullPhotoPath,FacePhotoPath,AnyPhotoPath,PendingVote,ImageName,ImageFile")] PendingPhotoRequest pendingPhotoRequest, IFormFile fullImageFile, IFormFile faceImageFile, IFormFile anyImageFile) { var user = await _userManager.GetUserAsync(User); if (user.UserLevel < 4) { return(NotFound($"User with this ID '{_userManager.GetUserId(User)}' can not see the content of this page.")); } if (ModelState.IsValid) { //Save image to wwwroot/image if (user == null) { return(NotFound($"Unable to load user with ID '{_userManager.GetUserId(User)}'.")); } string fullImageLink = await pendingPhotoRequest.UploadPhoto(fullImageFile, _hostEnvironment); string faceImageLink = await pendingPhotoRequest.UploadPhoto(faceImageFile, _hostEnvironment); string anyImageLink = await pendingPhotoRequest.UploadPhoto(anyImageFile, _hostEnvironment); var updateContext = new Pada_DataContext(); var output = new SqlParameter(); output.ParameterName = "@result"; output.SqlDbType = SqlDbType.Int; output.Direction = ParameterDirection.Output; updateContext.Database.ExecuteSqlInterpolated($"EXEC [dbo].[usp_minh_photorequest_createnewphoto] @email={user.Email},@password={"123456"},@fullphoto={fullImageLink},@facephoto ={faceImageLink},@anyphoto={anyImageLink}, @result = {output} OUT"); return(RedirectToAction("Index", "PhotoCheck", new { area = "" })); } return(View(pendingPhotoRequest)); }
public async Task <IActionResult> Edit(int id, [Bind("TransactionId,Email,Type,OldPhotoPath,NewPhotoPath,AcceptedVote,RejectedVote,VoteRequired,FullPhotoPath,FacePhotoPath,AnyPhotoPath,PendingVote")] PendingPhotoRequest pendingPhotoRequest) { var user = await _userManager.GetUserAsync(User); if (user.UserLevel < 4) { return(NotFound($"User with this ID '{_userManager.GetUserId(User)}' can not see the content of this page.")); } if (id != pendingPhotoRequest.TransactionId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(pendingPhotoRequest); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PendingPhotoRequestExists(pendingPhotoRequest.TransactionId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(pendingPhotoRequest)); }