public IResult Add(ChannelDto channelDto) { var userExist = _userService.GetById(channelDto.UserId); if (userExist == null) { return(new ErrorResult("Invalid user")); } var channel = new Channel { Name = channelDto.Name, Verified = false, UserId = channelDto.UserId }; if (!_channelDal.Add(channel)) { return(new ErrorResult("Channel cannot created!")); } channel.Slug = channel.Id.ToString(); _channelDal.Update(channel); return(new SuccessResult("Channel created.")); }
public IDataResult <Channel> Update(Channel channel) { _validation = new Validation <ChannelValidator>(); _validation.Validate(channel); _channelDal.Update(channel); return(new SuccessDataResult <Channel>(Messages.ChannelUpdated, channel)); }
public IResult Update(IFormFile channelPhotoFile, Channel channel) { IResult result = BusinessRule.Run ( CheckIfChannelExist(channel.Id) ); if (result != null) { return(result); } var channelToUpdate = _channelDal.Get(cp => cp.Id == channel.Id); _fileSystem.Update(channelPhotoFile, channelToUpdate.ChannelPhotoPath, _path); channel.InstallationDate = channelToUpdate.InstallationDate; channel.UpdateDate = DateTime.Now; _channelDal.Update(channel); return(new SuccessResult()); }