public override CommandResult Handle(UpdateWriterCommand command) { long addedPhotoId; if (IsValid(command)) { if (command.Photo != null) { addedPhotoId = _fileManagementCommandRepository.Add(new FileManagement { Url = command.Photo.FileUrl, Type = command.Photo.FileType, Name = command.Photo.FileName, Size = command.Photo.FileSize, Date = System.DateTime.Now }); _writerCommandRepository.ChangePhoto(command.WriterId, addedPhotoId); } if (command.Name != null) { _writerCommandRepository.EditName(new Writer { Id = command.WriterId, Name = command.Name, }); } return(Ok()); } return(Failure()); }
public override CommandResult Handle(AddWriterCommand entity) { long?photoId = null; if (IsValid(entity)) { if (entity.Photo != null) { photoId = _fileManagementCommandRepository.Add(new FileManagement { Url = entity.Photo.FileUrl, Type = entity.Photo.FileType, Name = entity.Photo.FileName, Size = entity.Photo.FileSize, Date = System.DateTime.Now }); } _writerCommandRepository.Add(new Writer() { Name = entity.Name, PhotoId = photoId }); return(Ok()); } return(Failure()); }
public override CommandResult Handle(AddFileCommand command) { if (IsValid(command)) { _fileManagementCommandRepository.Add(new FileManagement { Url = command.FileUrl, Type = command.FileType, Name = command.FileName, Size = command.FileSize, Date = System.DateTime.Now }); return(Ok()); } return(Failure()); }