public async Task <IActionResult> Update(CastUpdateDto castUpdateDto) { bool isNewPicUploaded = false; var oldUserPic = castUpdateDto.PicturePath; if (castUpdateDto.Picture != null) { castUpdateDto.PicturePath = await ImageExtensions.ImageUpload( castUpdateDto.FirstName + castUpdateDto.LastName, "casts", castUpdateDto.Picture, _env); isNewPicUploaded = true; } castUpdateDto.ModifiedByUserName = "******"; var updatedCast = await _castService.Update(castUpdateDto); if (updatedCast.ResultStatus == ResultStatus.Success) { if (isNewPicUploaded) { ImageExtensions.ImageDelete(oldUserPic, "casts", _env); } return(Json(0)); } return(Json(1)); }
public async Task <IActionResult> Update(DirectorUpdateDto directorUpdateDto) { bool isNewPicUploaded = false; var oldUserPic = directorUpdateDto.PicturePath; if (directorUpdateDto.Picture != null) { directorUpdateDto.PicturePath = await ImageExtensions.ImageUpload( directorUpdateDto.FirstName + directorUpdateDto.LastName, "directors", directorUpdateDto.Picture, _env); isNewPicUploaded = true; } directorUpdateDto.ModifiedByUserName = "******"; var updatedDirectors = await _directorService.Update(directorUpdateDto); if (updatedDirectors.ResultStatus == ResultStatus.Success) { if (isNewPicUploaded) { ImageExtensions.ImageDelete(oldUserPic, "directors", _env); } return(Json(0)); } return(Json(1)); }
public async Task <IActionResult> Insert(CastInsertDto castInsertDto) { castInsertDto.CreatedByUserName = "******"; castInsertDto.ModifiedByUserName = "******"; castInsertDto.PicturePath = await ImageExtensions.ImageUpload( castInsertDto.FirstName + castInsertDto.LastName, "casts", castInsertDto.Picture, _env); var insertedCast = await _castService.Insert(castInsertDto); if (insertedCast.ResultStatus == ResultStatus.Success) { return(Json(0)); } return(Json(1)); }
public async Task <IActionResult> Insert(DirectorInsertDto directorInsertDto) { directorInsertDto.CreatedByUserName = "******"; directorInsertDto.ModifiedByUserName = "******"; directorInsertDto.PicturePath = await ImageExtensions.ImageUpload( directorInsertDto.FirstName + directorInsertDto.LastName, "directors", directorInsertDto.Picture, _env); var insertedDirector = await _directorService.Insert(directorInsertDto); if (insertedDirector.ResultStatus == ResultStatus.Success) { return(Json(0)); } return(Json(1)); }
public async Task <JsonResult> Insert(MovieInsertDto movieInsertDto) { var user = _userManager.GetUserAsync(HttpContext.User).Result; movieInsertDto.CreatedByUserName = user.UserName; movieInsertDto.ModifiedByUserName = user.UserName; movieInsertDto.PosterPath = await ImageExtensions.ImageUpload( movieInsertDto.Name, $"movies/{movieInsertDto.Name}", movieInsertDto.Poster, _env); //Username var insertedMovie = await _movieService.Insert(movieInsertDto); if (insertedMovie.ResultStatus == ResultStatus.Success) { return(Json(0)); } return(Json(1)); }