public IActionResult Put(int channelId, [FromForm] ChannelForUpdateDto channelForUpdate) { var dataResult = _channelService.GetById(channelId); if (dataResult.IsSuccessful) { if (string.IsNullOrEmpty(channelForUpdate.Name)) { return(BadRequest()); } if (channelForUpdate.File != null && channelForUpdate.File.Length > 0 && BusinessRules.ImageExtensionValidate(channelForUpdate.File.ContentType).IsSuccessful) { DeletionResult deletionResult = _photoUpload.ImageDelete(dataResult.Data.PublicId); ImageUploadResult imageUploadResult = _photoUpload.ImageUpload(channelForUpdate.File); dataResult.Data.ChannelPhotoUrl = imageUploadResult.Uri.ToString(); dataResult.Data.PublicId = imageUploadResult.PublicId; } IResult result = _channelService.CheckIfChannelNameExistsWithUpdate(channelForUpdate.Name, channelId); if (result.IsSuccessful) { return(BadRequest(result.Message)); } dataResult.Data.Name = channelForUpdate.Name; IDataResult <Channel> updateDataResult = _channelService.Update(dataResult.Data); if (dataResult.IsSuccessful) { var map = _mapper.Map <ChannelForDetailDto>(updateDataResult.Data); map.SubscribersCount = _countService.GetSubscriberCount(map.Id).Data; this.RemoveCache(); return(Ok(map)); } return(this.ServerError()); } return(NotFound(dataResult.Message)); }