Exemplo n.º 1
0
        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));
        }
Exemplo n.º 2
0
        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));
        }
Exemplo n.º 3
0
        public async Task <IActionResult> Delete(int castId)
        {
            var deletedCast = await _castService.Delete(castId);

            if (deletedCast != null)
            {
                ImageExtensions.ImageDelete(deletedCast.Data.PicturePath, "casts", _env);
                return(Json(0));
            }
            return(Json(1));
        }
Exemplo n.º 4
0
        public async Task <IActionResult> Delete(int directorId)
        {
            var deletedDirector = await _directorService.Delete(directorId);

            if (deletedDirector != null)
            {
                ImageExtensions.ImageDelete(deletedDirector.Data.PicturePath, "directors", _env);
                return(Json(0));
            }
            return(Json(1));
        }